Inbound.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. },
  52. data(){
  53. return{
  54. type:undefined,
  55. rules:{
  56. teamName:{
  57. rules:[
  58. {
  59. required: true,
  60. errorMessage: '请输入队伍名称'
  61. }
  62. ],
  63. validateTrigger:'submit'
  64. },
  65. teamCatId:{
  66. rules:[
  67. {
  68. required: true,
  69. errorMessage: '请选择队伍类别',
  70. }
  71. ],
  72. validateTrigger:'submit'
  73. },
  74. },
  75. userList:[],
  76. form:{
  77. teamId: 0,
  78. teamName: '',
  79. teamType: 1,
  80. teamCatId: 1,
  81. teamDuty: '',
  82. teamDesc: '',
  83. sortNo: 1
  84. }
  85. }
  86. },
  87. methods:{
  88. resetForm(){
  89. this.form={
  90. teamId: 0,
  91. teamName: '',
  92. teamType: 1,
  93. teamCatId: 1,
  94. teamDuty: '',
  95. teamDesc: '',
  96. sortNo: 1
  97. }
  98. },
  99. init(){
  100. let groupUser=uni.getStorageSync('groupUser')
  101. let userList=[]
  102. groupUser.map((item,index)=>{
  103. userList.push({...item,value:`root-${index+1}`,text:item.name,disable:true})
  104. if(Array.isArray(item.children)&&item.children.length>0){
  105. userList=userList.concat(item.children.map(item=>{return{...item,value:item.accountId,text:item.accountName}}))
  106. }
  107. })
  108. this.userList=userList
  109. },
  110. onSubmit(){
  111. this.$refs.form.validate().then(res=>{
  112. let submitFx=this.type==='add'?teamApi.create:teamApi.update
  113. submitFx(this.form).then(()=>{
  114. uni.showToast({
  115. icon:"none",
  116. title:"成功!!"
  117. })
  118. this.$emit('success')
  119. this.close();
  120. })
  121. }).catch(err =>{
  122. uni.showToast({
  123. icon:"none",
  124. title:"请检查填写信息!"
  125. })
  126. })
  127. },
  128. show(type,item){
  129. this.resetForm()
  130. if(type==='edit'){
  131. this.form={...item}
  132. }else{
  133. this.form.teamType=item
  134. }
  135. this.type=type
  136. this.$refs.drawer.open()
  137. },
  138. close(){
  139. this.$refs.drawer.close()
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .scroll-view {
  146. height: 100%;
  147. padding: 20rpx;
  148. box-sizing: border-box;
  149. .form-wrap{
  150. padding:40rpx;
  151. .handle-container{
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. button{
  156. width: 160rpx;
  157. padding: 20rpx 16rpx;
  158. line-height: 1;
  159. font-size: 28rpx;
  160. &.save{
  161. background-color: #007aff;
  162. }
  163. }
  164. }
  165. .word-limit{
  166. text-align: right;
  167. padding: 10rpx 0;
  168. color: #999;
  169. font-size: 26rpx;
  170. }
  171. }
  172. }
  173. </style>