basicInfoModal.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. // 更新价格显示
  124. updateShelfPriceShow({
  125. shelfSn: form.shelfSn,
  126. paramValue: form.showPrice
  127. }).then(ret => {
  128. if (ret.status == 200) {
  129. _this.$message.success(ret.message)
  130. setTimeout(() => {
  131. _this.isShow = false
  132. _this.$emit('ok', res.data)
  133. _this.spinning = false
  134. }, 100)
  135. } else {
  136. _this.spinning = false
  137. }
  138. })
  139. } else {
  140. _this.spinning = false
  141. }
  142. })
  143. } else {
  144. console.log('error submit!!')
  145. return false
  146. }
  147. })
  148. }
  149. },
  150. watch: {
  151. // 父页面传过来的弹框状态
  152. openModal (newValue, oldValue) {
  153. this.isShow = newValue
  154. },
  155. // 重定义的弹框状态
  156. isShow (newValue, oldValue) {
  157. if (!newValue) {
  158. this.$emit('close')
  159. this.$refs.ruleForm.resetFields()
  160. this.$refs.custList.resetForm()
  161. } else {
  162. const _this = this
  163. this.$nextTick(() => {
  164. _this.form.shelfName = _this.nowData.shelfName
  165. _this.form.showPrice = _this.nowData.showPrice
  166. const custome = _this.nowData.customerEntity
  167. if (custome) {
  168. _this.form.customerSn = custome.customerSn || ''
  169. _this.$refs.custList.fetchUser(custome.customerName || '')
  170. _this.$refs.custList.dealerName = {
  171. key: custome.customerSn,
  172. label: custome.customerName,
  173. row: _this.nowData
  174. }
  175. }
  176. })
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="less">
  183. .shelfSet-basicInfo-modal {
  184. .ant-modal-body {
  185. padding: 40px 40px 24px;
  186. }
  187. .ant-form-item{
  188. margin-bottom: 15px;
  189. }
  190. .btn-cont {
  191. text-align: center;
  192. margin: 35px 0 10px;
  193. }
  194. }
  195. </style>