addModal.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <a-modal
  3. centered
  4. class="businessOwnerSettings-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="itemId ?'编辑人员':'新增人员'"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="600">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. ref="ruleForm"
  14. :model="form"
  15. :label-col="labelCol"
  16. :wrapper-col="wrapperCol"
  17. :rules="rules"
  18. >
  19. <a-form-model-item label="人员名称" prop="userSn">
  20. <userName ref="userName" id="businessOwnerSettings-userSn" @change="userChange"></userName>
  21. </a-form-model-item>
  22. <a-form-model-item label="人员类型" prop="bizUserType">
  23. <v-select
  24. v-model="form.bizUserType"
  25. ref="printStatus"
  26. id="businessOwnerSettings-printStatus"
  27. code="BIZ_USER_TYPE"
  28. placeholder="请选择人员类型"
  29. allowClear></v-select>
  30. </a-form-model-item>
  31. <a-form-model-item label="管辖经销商" prop="allDealerFlag">
  32. <a-radio-group v-model="form.allDealerFlag">
  33. <a-radio value="1">
  34. 全部经销商
  35. </a-radio>
  36. <a-radio value="0">
  37. 部分经销商
  38. </a-radio>
  39. </a-radio-group>
  40. </a-form-model-item>
  41. <a-form-model-item label="管辖品类" prop="allProductFlag">
  42. <a-radio-group v-model="form.allProductFlag">
  43. <a-radio value="1">
  44. 全部品类
  45. </a-radio>
  46. <a-radio value="0">
  47. 部分品类
  48. </a-radio>
  49. </a-radio-group>
  50. </a-form-model-item>
  51. <!-- 供应商 -->
  52. <a-form-model-item label="供应商" prop="allSupplierFlag" v-if="form.bizUserType == 'cg'">
  53. <a-radio-group v-model="form.allSupplierFlag">
  54. <a-radio value="1">
  55. 全部供应商
  56. </a-radio>
  57. <a-radio value="0">
  58. 部分供应商
  59. </a-radio>
  60. </a-radio-group>
  61. </a-form-model-item>
  62. <!-- 人员类型为仓库管理员时 显示管辖仓库 -->
  63. <a-form-model-item label="管辖仓库" prop="bizUserScopeList" v-if="form.bizUserType == 'cg'">
  64. <chooseWarehouse ref="warehouse" modeType="multiple" :value="warehouseList" @change="handleWarehouse"></chooseWarehouse>
  65. </a-form-model-item>
  66. <div style="display: flex;justify-content: center;padding: 30px 0;">
  67. <a-button type="primary" @click="handleSave">{{ itemId?'保存':'确定' }}</a-button>
  68. <a-button style="margin-left: 15px;" @click="isShow=false">取消</a-button>
  69. </div>
  70. </a-form-model>
  71. </a-spin>
  72. </a-modal>
  73. </template>
  74. <script>
  75. import userName from '@/views/common/userName'
  76. import chooseWarehouse from '@/views/common/chooseWarehouse'
  77. import { VSelect } from '@/components'
  78. import { bizuserSave } from '@/api/bizuser.js'
  79. export default {
  80. name: 'ProductInfoDetailModal',
  81. components: { VSelect, userName, chooseWarehouse },
  82. props: {
  83. openModal: { // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. itemId: {
  88. type: String,
  89. default: ''
  90. }
  91. },
  92. data () {
  93. return {
  94. spinning: false,
  95. isShow: this.openModal, // 是否打开弹框
  96. form: {
  97. userSn: '',
  98. bizUserType: undefined, // 人员类型
  99. allDealerFlag: undefined,
  100. allProductFlag: undefined,
  101. bizUserScopeList: [],
  102. allSupplierFlag: undefined
  103. },
  104. warehouseList: [],
  105. user_name: '',
  106. labelCol: { span: 5 },
  107. wrapperCol: { span: 16 },
  108. rules: {
  109. userSn: [{ required: true, message: '请输入人员名称', trigger: 'change' }],
  110. bizUserType: [{ required: true, message: '请选择人员类型', trigger: 'change' }],
  111. allDealerFlag: [{ required: true, message: '请选择管辖经销商', trigger: 'change' }],
  112. allProductFlag: [{ required: true, message: '请选择管辖产品', trigger: 'change' }],
  113. bizUserScopeList: [{ required: true, message: '请选择管辖仓库', trigger: 'change' }],
  114. allSupplierFlag: [{ required: true, message: '请选择供应商', trigger: 'change' }]
  115. }
  116. }
  117. },
  118. methods: {
  119. handleSave () {
  120. const _this = this
  121. this.$refs.ruleForm.validate(valid => {
  122. if (valid) {
  123. _this.spinning = true
  124. _this.form.id = _this.itemId ? _this.itemId : ''
  125. if (_this.form.bizUserType != 'cg') {
  126. _this.warehouseList = []
  127. _this.form.bizUserScopeList = []
  128. _this.form.allSupplierFlag = undefined
  129. }
  130. bizuserSave(_this.form).then(res => {
  131. _this.spinning = false
  132. if (res.status == 200) {
  133. _this.$emit('ok', res.data)
  134. _this.isShow = false
  135. }
  136. }).catch(err => {
  137. _this.spinning = false
  138. })
  139. } else {
  140. console.log('error submit!!')
  141. return false
  142. }
  143. })
  144. },
  145. handleWarehouse (val) {
  146. this.warehouseList = val
  147. const arr = []
  148. val.forEach(item => {
  149. const obj = {
  150. bizSn: item
  151. }
  152. arr.push(obj)
  153. })
  154. this.form.bizUserScopeList = arr
  155. },
  156. resetSearchForm () {
  157. this.user_name = ''
  158. if (this.form.bizUserType && this.form.bizUserType == 'cg') {
  159. this.$refs.warehouse.clearData()
  160. this.form.bizUserScopeList = []
  161. }
  162. this.$refs.userName.resetForm()
  163. this.$refs.ruleForm.resetFields()
  164. },
  165. userChange (val) {
  166. this.form.userSn = val.key
  167. },
  168. getEditInfo (obj) {
  169. this.$refs.userName.setDufaultVal(obj.userName)
  170. const arr = []
  171. const newarr = []
  172. if (obj.warehouseList && obj.warehouseList.length > 0) {
  173. obj.warehouseList.forEach(item => {
  174. arr.push(item.warehouseSn)
  175. const newObj = {
  176. bizSn: item.warehouseSn
  177. }
  178. newarr.push(newObj)
  179. })
  180. this.warehouseList = arr
  181. }
  182. this.form = {
  183. userSn: obj.userSn,
  184. bizUserType: obj.bizUserType, // 人员类型
  185. allDealerFlag: obj.allDealerFlag,
  186. allProductFlag: obj.allProductFlag,
  187. bizUserScopeList: newarr,
  188. allSupplierFlag: obj.allSupplierFlag
  189. }
  190. }
  191. },
  192. watch: {
  193. // 父页面传过来的弹框状态
  194. openModal (newValue, oldValue) {
  195. this.isShow = newValue
  196. },
  197. // 重定义的弹框状态
  198. isShow (newValue, oldValue) {
  199. if (!newValue) {
  200. this.resetSearchForm()
  201. this.$emit('close')
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="less">
  208. .inventoryCheckAddModal-modal{
  209. .ant-modal-body {
  210. padding: 30px 40px 24px;
  211. }
  212. .inventoryCheckAddModal-con{
  213. text-align: center;
  214. h3{
  215. font-size: 16px;
  216. font-weight: bold;
  217. margin-bottom: 25px;
  218. }
  219. }
  220. .btn-cont {
  221. text-align: center;
  222. margin: 35px 0 10px;
  223. }
  224. }
  225. </style>