basicInfoModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <a-modal
  3. centered
  4. class="shelfSet-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="数字货架基础设置"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. :width="600">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <p v-if="type==0" style="text-align: center;margin: 0 0 20px;font-size: 14px;font-weight: bold;">{{ nowData && nowData.shelfName || '--' }}</p>
  13. <a-form-model
  14. id="shelfSet-basicInfo-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol">
  20. <a-form-model-item label="货架名称" v-if="type==1" prop="shelfName">
  21. <a-input v-model="form.shelfName" :maxLength="30" placeholder="请输入货架名称"></a-input>
  22. </a-form-model-item>
  23. <a-form-model-item prop="customerSn">
  24. <template slot="label">
  25. <a-tooltip placement="top">
  26. <template slot="title">
  27. <span>此数字货架,归属于您的哪一位客户。如果没有搜索到客户,请在客户管理功能中新建客户。</span>
  28. </template>
  29. 关联客户<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  30. </a-tooltip>
  31. </template>
  32. <custList ref="custList" :isEnabled="true" @change="custChange"></custList>
  33. </a-form-model-item>
  34. <!-- <a-form-model-item prop="showPrice">
  35. <template slot="label">
  36. <a-tooltip placement="top">
  37. <template slot="title">
  38. 1、非铺货产品,是指不是货架上的产品<br>
  39. 2、终端会员价,对于汽修厂来说,即进货价<br>
  40. 3、如果该产品在销售单里有销售记录,则使用最近一次销售价,如果没有销售记录,则使用箭冠总公司的终端会员价
  41. </template>
  42. 价格显示<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  43. </a-tooltip>
  44. </template>
  45. <a-select v-model="form.showPrice" placeholder="请选择价格显示">
  46. <a-select-option value="1">
  47. 非铺货产品——显示价格
  48. </a-select-option>
  49. <a-select-option value="0">
  50. 非铺货产品——不显示价格
  51. </a-select-option>
  52. </a-select>
  53. </a-form-model-item> -->
  54. </a-form-model>
  55. <div class="btn-cont">
  56. <a-button type="primary" id="shelfSet-basicInfo-modal-save" @click="handleSave">保存</a-button>
  57. <a-button id="shelfSet-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  58. </div>
  59. </a-spin>
  60. </a-modal>
  61. </template>
  62. <script>
  63. import { commonMixin } from '@/utils/mixin'
  64. import { VSelect } from '@/components'
  65. import custList from '@/views/common/custList.vue'
  66. // , updateShelfPriceShow
  67. import { shelfSave } from '@/api/shelf'
  68. export default {
  69. name: 'ShelfSetBasicInfoModal',
  70. components: { VSelect, custList },
  71. mixins: [commonMixin],
  72. props: {
  73. openModal: {
  74. // 弹框显示状态
  75. type: Boolean,
  76. default: false
  77. },
  78. nowData: {
  79. type: Object,
  80. default: () => {
  81. return {}
  82. }
  83. },
  84. type: {
  85. type: [String, Number],
  86. default: '1'
  87. }
  88. },
  89. data () {
  90. return {
  91. spinning: false,
  92. isShow: this.openModal, // 是否打开弹框
  93. formItemLayout: {
  94. labelCol: { span: 5 },
  95. wrapperCol: { span: 17 }
  96. },
  97. form: {
  98. customerSn: undefined,
  99. shelfName: '',
  100. showPrice: undefined
  101. },
  102. rules: {
  103. shelfName: [{ required: true, message: '请输入货架名称', trigger: 'change' }],
  104. customerSn: [{ required: true, message: '请选择关联客户', trigger: 'change' }],
  105. showPrice: [{ required: true, message: '请选择价格显示', trigger: 'change' }]
  106. }
  107. }
  108. },
  109. methods: {
  110. // 客户 change
  111. custChange (obj, row) {
  112. this.form.customerSn = row && row.customerSn || undefined
  113. },
  114. // 保存
  115. handleSave () {
  116. const _this = this
  117. this.$refs.ruleForm.validate(valid => {
  118. if (valid) {
  119. const form = JSON.parse(JSON.stringify(_this.form))
  120. form.shelfSn = _this.nowData && _this.nowData.shelfSn
  121. _this.spinning = true
  122. shelfSave(form).then(res => {
  123. if (res.status == 200) {
  124. _this.$message.success(res.message)
  125. setTimeout(() => {
  126. _this.isShow = false
  127. _this.$emit('ok', res.data)
  128. _this.spinning = false
  129. }, 100)
  130. // 更新价格显示
  131. // updateShelfPriceShow({
  132. // shelfSn: form.shelfSn,
  133. // paramValue: form.showPrice
  134. // }).then(ret => {
  135. // if (ret.status == 200) {
  136. // _this.$message.success(ret.message)
  137. // setTimeout(() => {
  138. // _this.isShow = false
  139. // _this.$emit('ok', res.data)
  140. // _this.spinning = false
  141. // }, 100)
  142. // } else {
  143. // _this.spinning = false
  144. // }
  145. // })
  146. } else {
  147. _this.spinning = false
  148. }
  149. })
  150. } else {
  151. console.log('error submit!!')
  152. return false
  153. }
  154. })
  155. }
  156. },
  157. watch: {
  158. // 父页面传过来的弹框状态
  159. openModal (newValue, oldValue) {
  160. this.isShow = newValue
  161. },
  162. // 重定义的弹框状态
  163. isShow (newValue, oldValue) {
  164. if (!newValue) {
  165. this.$emit('close')
  166. this.$refs.ruleForm.resetFields()
  167. this.$refs.custList.resetForm()
  168. } else {
  169. const _this = this
  170. this.$nextTick(() => {
  171. _this.form.shelfName = _this.nowData.shelfName
  172. _this.form.showPrice = _this.nowData.showPrice
  173. const custome = _this.nowData.customerEntity
  174. if (custome) {
  175. _this.form.customerSn = custome.customerSn || ''
  176. _this.$refs.custList.fetchUser(custome.customerName || '')
  177. _this.$refs.custList.dealerName = {
  178. key: custome.customerSn,
  179. label: custome.customerName,
  180. row: _this.nowData
  181. }
  182. }
  183. })
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="less">
  190. .shelfSet-basicInfo-modal {
  191. .ant-modal-body {
  192. padding: 40px 40px 24px;
  193. }
  194. .ant-form-item{
  195. margin-bottom: 15px;
  196. }
  197. .btn-cont {
  198. text-align: center;
  199. margin: 35px 0 10px;
  200. }
  201. }
  202. </style>