Inbound.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <uni-drawer ref="drawer" mode="left" :mask-click="false" width="85%" :maskClick='true'>
  3. <scroll-view class="scroll-view" scroll-y="true">
  4. <view class="form-wrap" >
  5. <uni-forms ref="form" label-position="top" :rules="rules" :model="form">
  6. <uni-forms-item label="队伍名称" name="teamName" required>
  7. <uni-easyinput v-model="form.teamName" placeholder="请输入队伍名称" :clearable="false" />
  8. </uni-forms-item>
  9. <uni-forms-item label="队伍类别" name="teamCatId" required>
  10. <uni-data-select v-model="form.teamCatId" :localdata="teamCats" placeholder="请选择值班人员" :clear="false"></uni-data-select>
  11. </uni-forms-item>
  12. <uni-forms-item label="出库人员" name="accountId" required>
  13. <uni-data-select v-model="form.accountId" :localdata="userList" placeholder="请选择出库人员" :clear="false"></uni-data-select>
  14. </uni-forms-item>
  15. <uni-forms-item label="职责说明">
  16. <uni-easyinput type="textarea" :maxlength="1000" v-model="form.teamDuty" placeholder="请输入职责说明" autoHeight ></uni-easyinput>
  17. <view class="word-limit">{{form.teamDuty.length||0}}/1000</view>
  18. </uni-forms-item>
  19. <uni-forms-item label="说明">
  20. <uni-easyinput type="textarea" :maxlength="500"
  21. v-model="form.teamDesc" autoHeight
  22. placeholder="请输入职责说明"></uni-easyinput>
  23. <view class="word-limit">{{form.teamDesc.length||0}}/500</view>
  24. </uni-forms-item>
  25. <uni-forms-item label="排序" v-model="form.sortNo">
  26. <uni-number-box :min="1"></uni-number-box>
  27. </uni-forms-item>
  28. </uni-forms>
  29. <view class="handle-container">
  30. <button class="save" type="primary" @click="onSubmit">保存</button>
  31. <button class="cancel" type="default" @click="close">取消</button>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </uni-drawer>
  36. </template>
  37. <script>
  38. import teamApi from '@/api/team.js'
  39. export default{
  40. name:"Inbound",
  41. computed:{
  42. teamCats(){
  43. let teamCats=uni.getStorageSync('teamCat')
  44. return teamCats.map(item=>{
  45. return{
  46. value:item.teamCatId,
  47. text:item.teamCatTitle
  48. }
  49. })
  50. },
  51. userList(){
  52. let groupUser=uni.getStorageSync('groupUser')
  53. let userList=[]
  54. groupUser.map((item,index)=>{
  55. userList.push({...item,value:`root-${index+1}`,text:item.name,disable:true})
  56. if(Array.isArray(item.children)&&item.children.length>0){
  57. userList=userList.concat(item.children.map(item=>{return{...item,value:item.accountId,text:item.accountName}}))
  58. }
  59. })
  60. return userList
  61. }
  62. },
  63. data(){
  64. return{
  65. type:undefined,
  66. rules:{
  67. teamName:{
  68. rules:[
  69. {
  70. required: true,
  71. errorMessage: '请输入队伍名称'
  72. }
  73. ],
  74. validateTrigger:'submit'
  75. },
  76. teamCatId:{
  77. rules:[
  78. {
  79. required: true,
  80. errorMessage: '请选择队伍类别',
  81. }
  82. ],
  83. validateTrigger:'submit'
  84. },
  85. },
  86. form:{
  87. teamId: 0,
  88. teamName: '',
  89. teamType: 1,
  90. teamCatId: 1,
  91. teamDuty: '',
  92. teamDesc: '',
  93. sortNo: 1
  94. }
  95. }
  96. },
  97. methods:{
  98. resetForm(){
  99. this.form={
  100. teamId: 0,
  101. teamName: '',
  102. teamType: 1,
  103. teamCatId: 1,
  104. teamDuty: '',
  105. teamDesc: '',
  106. sortNo: 1
  107. }
  108. },
  109. onSubmit(){
  110. this.$refs.form.validate().then(res=>{
  111. let submitFx=this.type==='add'?teamApi.create:teamApi.update
  112. submitFx(this.form).then(()=>{
  113. uni.showToast({
  114. icon:"none",
  115. title:"成功!!"
  116. })
  117. this.$emit('success')
  118. this.close();
  119. })
  120. }).catch(err =>{
  121. uni.showToast({
  122. icon:"none",
  123. title:"请检查填写信息!"
  124. })
  125. })
  126. },
  127. show(type,item){
  128. this.resetForm()
  129. if(type==='edit'){
  130. this.form={...item}
  131. }else{
  132. this.form.teamType=item
  133. }
  134. this.type=type
  135. this.$refs.drawer.open()
  136. },
  137. close(){
  138. this.$refs.drawer.close()
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .scroll-view {
  145. height: 100%;
  146. padding: 20rpx;
  147. box-sizing: border-box;
  148. .form-wrap{
  149. padding:40rpx;
  150. .handle-container{
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. button{
  155. width: 160rpx;
  156. padding: 20rpx 16rpx;
  157. line-height: 1;
  158. font-size: 28rpx;
  159. &.save{
  160. background-color: #007aff;
  161. }
  162. }
  163. }
  164. .word-limit{
  165. text-align: right;
  166. padding: 10rpx 0;
  167. color: #999;
  168. font-size: 26rpx;
  169. }
  170. }
  171. }
  172. </style>