basicInfoModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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" 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. import { shelfSave, updateShelfPriceShow } from '@/api/shelf'
  67. export default {
  68. name: 'ShelfSetBasicInfoModal',
  69. components: { VSelect, custList },
  70. mixins: [commonMixin],
  71. props: {
  72. openModal: {
  73. // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. nowData: {
  78. type: Object,
  79. default: () => {
  80. return {}
  81. }
  82. },
  83. type: {
  84. type: [String, Number],
  85. default: '1'
  86. }
  87. },
  88. data () {
  89. return {
  90. spinning: false,
  91. isShow: this.openModal, // 是否打开弹框
  92. formItemLayout: {
  93. labelCol: { span: 5 },
  94. wrapperCol: { span: 17 }
  95. },
  96. form: {
  97. customerSn: undefined,
  98. shelfName: ''
  99. // showPrice: undefined
  100. },
  101. rules: {
  102. shelfName: [{ required: true, message: '请输入货架名称', trigger: 'change' }],
  103. customerSn: [{ required: true, message: '请选择关联客户', trigger: 'change' }]
  104. // showPrice: [{ required: true, message: '请选择价格显示', trigger: 'change' }]
  105. }
  106. }
  107. },
  108. methods: {
  109. // 客户 change
  110. custChange (obj, row) {
  111. this.form.customerSn = row && row.customerSn || undefined
  112. },
  113. // 保存
  114. handleSave () {
  115. const _this = this
  116. this.$refs.ruleForm.validate(valid => {
  117. if (valid) {
  118. const form = JSON.parse(JSON.stringify(_this.form))
  119. form.shelfSn = _this.nowData && _this.nowData.shelfSn
  120. _this.spinning = true
  121. shelfSave(form).then(res => {
  122. if (res.status == 200) {
  123. _this.$message.success(res.message)
  124. setTimeout(() => {
  125. _this.isShow = false
  126. _this.$emit('ok', res.data)
  127. _this.spinning = false
  128. }, 100)
  129. // 更新价格显示
  130. // updateShelfPriceShow({
  131. // shelfSn: form.shelfSn,
  132. // paramValue: form.showPrice
  133. // }).then(ret => {
  134. // if (ret.status == 200) {
  135. // _this.$message.success(ret.message)
  136. // setTimeout(() => {
  137. // _this.isShow = false
  138. // _this.$emit('ok', res.data)
  139. // _this.spinning = false
  140. // }, 100)
  141. // } else {
  142. // _this.spinning = false
  143. // }
  144. // })
  145. } else {
  146. _this.spinning = false
  147. }
  148. })
  149. } else {
  150. console.log('error submit!!')
  151. return false
  152. }
  153. })
  154. }
  155. },
  156. watch: {
  157. // 父页面传过来的弹框状态
  158. openModal (newValue, oldValue) {
  159. this.isShow = newValue
  160. },
  161. // 重定义的弹框状态
  162. isShow (newValue, oldValue) {
  163. if (!newValue) {
  164. this.$emit('close')
  165. this.$refs.ruleForm.resetFields()
  166. this.$refs.custList.resetForm()
  167. } else {
  168. const _this = this
  169. this.$nextTick(() => {
  170. _this.form.shelfName = _this.nowData.shelfName
  171. _this.form.showPrice = _this.nowData.showPrice
  172. const custome = _this.nowData.customerEntity
  173. if (custome) {
  174. _this.form.customerSn = custome.customerSn || ''
  175. _this.$refs.custList.fetchUser(custome.customerName || '')
  176. _this.$refs.custList.dealerName = {
  177. key: custome.customerSn,
  178. label: custome.customerName,
  179. row: _this.nowData
  180. }
  181. }
  182. })
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="less">
  189. .shelfSet-basicInfo-modal {
  190. .ant-modal-body {
  191. padding: 40px 40px 24px;
  192. }
  193. .ant-form-item{
  194. margin-bottom: 15px;
  195. }
  196. .btn-cont {
  197. text-align: center;
  198. margin: 35px 0 10px;
  199. }
  200. }
  201. </style>