basicInfoModal.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 id="shelfSet-basicInfo-modal-shelfName" 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 id="shelfSet-basicInfo-modal-custList" ref="custList" :isEnabled="true" @change="custChange"></custList>
  33. </a-form-model-item>
  34. <a-form-model-item prop="showPrice" v-if="$hasPermissions('B_shelfSet_priceSetting')">
  35. <template slot="label">
  36. <a-tooltip placement="top">
  37. <template slot="title">
  38. 不勾选则不显示价格,结算价:即易码通进货价。
  39. </template>
  40. 价格权限设置<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
  41. </a-tooltip>
  42. </template>
  43. <a-checkbox-group v-model="form.showPrice" id="shelfSet-basicInfo-showPrice-checkbox">
  44. <div style="display: flex;padding:10px 0;">
  45. <div style="width: 80px;font-weight: bold;">货架产品:</div>
  46. <a-checkbox value="shelf_price_show" id="shelf_price_show">
  47. 车主价
  48. </a-checkbox>
  49. <a-checkbox value="shelf_cost_show" id="shelf_cost_show">
  50. 结算价
  51. </a-checkbox>
  52. </div>
  53. <div style="display: flex;padding:10px 0;">
  54. <div style="width: 80px;font-weight: bold;">非货架产品:</div>
  55. <a-checkbox value="non_shelf_price_show" id="non_shelf_price_show">
  56. 车主价
  57. </a-checkbox>
  58. <a-checkbox value="non_shelf_cost_show" id="non_shelf_cost_show">
  59. 结算价
  60. </a-checkbox>
  61. </div>
  62. </a-checkbox-group>
  63. </a-form-model-item>
  64. </a-form-model>
  65. <div class="btn-cont">
  66. <a-button type="primary" id="shelfSet-basicInfo-modal-save" @click="handleSave">保存</a-button>
  67. <a-button id="shelfSet-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  68. </div>
  69. </a-spin>
  70. </a-modal>
  71. </template>
  72. <script>
  73. import { commonMixin } from '@/utils/mixin'
  74. import { VSelect } from '@/components'
  75. import custList from '@/views/common/custList.vue'
  76. import { shelfSave, updateShelfPriceShow } from '@/api/shelf'
  77. export default {
  78. name: 'ShelfSetBasicInfoModal',
  79. components: { VSelect, custList },
  80. mixins: [commonMixin],
  81. props: {
  82. openModal: {
  83. // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. nowData: { // 当前操作数据
  88. type: Object,
  89. default: () => {
  90. return {}
  91. }
  92. },
  93. type: { // 新增or查看
  94. type: [String, Number],
  95. default: '1'
  96. }
  97. },
  98. data () {
  99. return {
  100. spinning: false,
  101. isShow: this.openModal, // 是否打开弹框
  102. formItemLayout: {
  103. labelCol: { span: 6 },
  104. wrapperCol: { span: 17 }
  105. },
  106. form: {
  107. customerSn: undefined, // 关联客户sn
  108. shelfName: '', // 货架名称
  109. showPrice: undefined // 价格显示
  110. },
  111. rules: {
  112. shelfName: [{ required: true, message: '请输入货架名称', trigger: 'change' }],
  113. customerSn: [{ required: true, message: '请选择关联客户', trigger: 'change' }]
  114. // showPrice: [{ required: true, message: '请选择价格显示', trigger: 'change' }]
  115. }
  116. }
  117. },
  118. methods: {
  119. // 选择关联客户
  120. custChange (obj, row) {
  121. this.form.customerSn = row && row.customerSn || undefined
  122. },
  123. // 保存
  124. handleSave () {
  125. const _this = this
  126. this.$refs.ruleForm.validate(valid => {
  127. if (valid) {
  128. const form = JSON.parse(JSON.stringify(_this.form))
  129. form.shelfSn = _this.nowData && _this.nowData.shelfSn
  130. _this.spinning = true
  131. // 保存货架信息
  132. shelfSave(form).then(res => {
  133. if (res.status == 200) {
  134. const paramValue = []
  135. this.nowData.showPrice.map(item => {
  136. paramValue.push({
  137. paramCode: item.paramCode,
  138. paramValue: form.showPrice.includes(item.paramCode) ? 1 : 0
  139. })
  140. })
  141. // 更新价格显示设置
  142. updateShelfPriceShow({
  143. shelfSn: form.shelfSn,
  144. paramValue: paramValue
  145. }).then(ret => {
  146. if (ret.status == 200) {
  147. _this.$message.success(ret.message)
  148. setTimeout(() => {
  149. _this.isShow = false
  150. _this.$emit('ok', res.data)
  151. _this.spinning = false
  152. }, 100)
  153. } else {
  154. _this.spinning = false
  155. }
  156. })
  157. } else {
  158. _this.spinning = false
  159. }
  160. })
  161. } else {
  162. return false
  163. }
  164. })
  165. }
  166. },
  167. watch: {
  168. // 父页面传过来的弹框状态
  169. openModal (newValue, oldValue) {
  170. this.isShow = newValue
  171. },
  172. // 重定义的弹框状态
  173. isShow (newValue, oldValue) {
  174. if (!newValue) {
  175. this.$emit('close')
  176. this.$refs.ruleForm.resetFields()
  177. this.$refs.custList.resetForm()
  178. } else {
  179. const _this = this
  180. this.$nextTick(() => {
  181. _this.form.shelfName = _this.nowData.shelfName
  182. _this.form.showPrice = _this.nowData.showPrice.filter(item => item.paramValue == 1).map(item => item.paramCode)
  183. const custome = _this.nowData.customerEntity
  184. // 如果关联了客户
  185. if (custome) {
  186. _this.form.customerSn = custome.customerSn || ''
  187. _this.$refs.custList.fetchUser(custome.customerName || '')
  188. _this.$refs.custList.dealerName = {
  189. key: custome.customerSn,
  190. label: custome.customerName,
  191. row: _this.nowData
  192. }
  193. }
  194. })
  195. }
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. .shelfSet-basicInfo-modal {
  202. .ant-modal-body {
  203. padding: 40px 40px 24px;
  204. }
  205. .ant-form-item{
  206. margin-bottom: 15px;
  207. }
  208. .btn-cont {
  209. text-align: center;
  210. margin: 35px 0 10px;
  211. }
  212. }
  213. </style>