123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <template>
- <a-modal
- centered
- class="shelfSet-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- title="数字货架基础设置"
- v-model="isShow"
- @cancel="isShow = false"
- :width="600">
- <a-spin :spinning="spinning" tip="Loading...">
- <p v-if="type==0" style="text-align: center;margin: 0 0 20px;font-size: 14px;font-weight: bold;">{{ nowData && nowData.shelfName || '--' }}</p>
- <a-form-model
- id="shelfSet-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol">
- <a-form-model-item label="货架名称" v-if="type==1" prop="shelfName">
- <a-input id="shelfSet-basicInfo-modal-shelfName" v-model="form.shelfName" :maxLength="30" placeholder="请输入货架名称"></a-input>
- </a-form-model-item>
- <a-form-model-item prop="customerSn">
- <template slot="label">
- <a-tooltip placement="top">
- <template slot="title">
- <span>此数字货架,归属于您的哪一位客户。如果没有搜索到客户,请在客户管理功能中新建客户。</span>
- </template>
- 关联客户<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
- </a-tooltip>
- </template>
- <custList id="shelfSet-basicInfo-modal-custList" ref="custList" :isEnabled="true" @change="custChange"></custList>
- </a-form-model-item>
- <a-form-model-item prop="showPrice" v-if="$hasPermissions('B_shelfSet_priceSetting')">
- <template slot="label">
- <a-tooltip placement="top">
- <template slot="title">
- 不勾选则不显示价格,结算价:即易码通进货价。
- </template>
- 价格权限设置<a-icon type="question-circle" style="color: rgba(0,0,0,.65);font-size: 16px;margin-left: 2px;vertical-align: sub;cursor: pointer;" />
- </a-tooltip>
- </template>
- <a-checkbox-group v-model="form.showPrice" id="shelfSet-basicInfo-showPrice-checkbox">
- <div style="display: flex;padding:10px 0;">
- <div style="width: 80px;font-weight: bold;">货架产品:</div>
- <a-checkbox value="shelf_price_show" id="shelf_price_show">
- 车主价
- </a-checkbox>
- <a-checkbox value="shelf_cost_show" id="shelf_cost_show">
- 结算价
- </a-checkbox>
- </div>
- <div style="display: flex;padding:10px 0;">
- <div style="width: 80px;font-weight: bold;">非货架产品:</div>
- <a-checkbox value="non_shelf_price_show" id="non_shelf_price_show">
- 车主价
- </a-checkbox>
- <a-checkbox value="non_shelf_cost_show" id="non_shelf_cost_show">
- 结算价
- </a-checkbox>
- </div>
- </a-checkbox-group>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button type="primary" id="shelfSet-basicInfo-modal-save" @click="handleSave">保存</a-button>
- <a-button id="shelfSet-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import custList from '@/views/common/custList.vue'
- import { shelfSave, updateShelfPriceShow } from '@/api/shelf'
- export default {
- name: 'ShelfSetBasicInfoModal',
- components: { VSelect, custList },
- mixins: [commonMixin],
- props: {
- openModal: {
- // 弹框显示状态
- type: Boolean,
- default: false
- },
- nowData: { // 当前操作数据
- type: Object,
- default: () => {
- return {}
- }
- },
- type: { // 新增or查看
- type: [String, Number],
- default: '1'
- }
- },
- data () {
- return {
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 17 }
- },
- form: {
- customerSn: undefined, // 关联客户sn
- shelfName: '', // 货架名称
- showPrice: undefined // 价格显示
- },
- rules: {
- shelfName: [{ required: true, message: '请输入货架名称', trigger: 'change' }],
- customerSn: [{ required: true, message: '请选择关联客户', trigger: 'change' }]
- // showPrice: [{ required: true, message: '请选择价格显示', trigger: 'change' }]
- }
- }
- },
- methods: {
- // 选择关联客户
- custChange (obj, row) {
- this.form.customerSn = row && row.customerSn || undefined
- },
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- form.shelfSn = _this.nowData && _this.nowData.shelfSn
- _this.spinning = true
- // 保存货架信息
- shelfSave(form).then(res => {
- if (res.status == 200) {
- const paramValue = []
- this.nowData.showPrice.map(item => {
- paramValue.push({
- paramCode: item.paramCode,
- paramValue: form.showPrice.includes(item.paramCode) ? 1 : 0
- })
- })
- // 更新价格显示设置
- updateShelfPriceShow({
- shelfSn: form.shelfSn,
- paramValue: paramValue
- }).then(ret => {
- if (ret.status == 200) {
- _this.$message.success(ret.message)
- setTimeout(() => {
- _this.isShow = false
- _this.$emit('ok', res.data)
- _this.spinning = false
- }, 100)
- } else {
- _this.spinning = false
- }
- })
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$refs.ruleForm.resetFields()
- this.$refs.custList.resetForm()
- } else {
- const _this = this
- this.$nextTick(() => {
- _this.form.shelfName = _this.nowData.shelfName
- _this.form.showPrice = _this.nowData.showPrice.filter(item => item.paramValue == 1).map(item => item.paramCode)
- const custome = _this.nowData.customerEntity
- // 如果关联了客户
- if (custome) {
- _this.form.customerSn = custome.customerSn || ''
- _this.$refs.custList.fetchUser(custome.customerName || '')
- _this.$refs.custList.dealerName = {
- key: custome.customerSn,
- label: custome.customerName,
- row: _this.nowData
- }
- }
- })
- }
- }
- }
- }
- </script>
- <style lang="less">
- .shelfSet-basicInfo-modal {
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .ant-form-item{
- margin-bottom: 15px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|