123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873 |
- <template>
- <a-modal
- centered
- class="promotionList-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- title="规则设置"
- v-model="isShow"
- @cancel="isShow=false"
- width="83%">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="promotionList-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol" >
- <a-form-model-item label="规则简称" prop="description">
- <a-input
- size="small"
- id="promotionList-description"
- v-model.trim="form.description"
- allowClear
- placeholder="请输入规则简称(最多20个字符)"
- :maxLength="20"></a-input>
- </a-form-model-item>
- <a-form-model-item label="规则门槛" prop="gateFlag">
- <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="handleChange">
- <a-radio-button value="1">
- 有
- </a-radio-button>
- <a-radio-button value="0">
- 无
- </a-radio-button>
- </a-radio-group>
- <div v-if="form.gateFlag && form.gateFlag === '1'">
- <v-select
- size="small"
- style="width:60%;"
- v-model="form.gateType"
- id="promotionList-gateType"
- code="PROMOTION_GATE_TYPE"
- placeholder="请选择门槛与配额设置要求"
- @change="changeGateTypeFlag"
- allowClear></v-select>
- <div v-if="form.gateType==='RATIO_AMOUNT'">
- 购买门槛产品金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/> %作为配额
- <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买特价产品,根据门槛金额动态调整配额">
- <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
- </a-tooltip>
- </div>
- <div v-if="form.gateType==='MIN_AMOUNT'">
- 购买门槛产品满最低金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>元,不限制配额。
- </div>
- <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
- 购买每满
- <a-input-number v-model="form.gateValue" :max="999999" :min="0" :precision="form.gateUnit=='YUAN'?2:0" size="small"/>
- <a-select default-value="GE" v-model="form.gateUnit" style="width: 50px;margin-left:5px;" size="small" @change="handleUnit">
- <a-select-option value="GE">
- 个
- </a-select-option>
- <a-select-option value="YUAN">
- 元
- </a-select-option>
- </a-select>
- 门槛产品,可采购
- <a-input-number v-model="form.quotaAmount" :max="999999" :min="0" :precision="0" size="small"/>
- 个特价产品(配额算销售额)
- </div>
- </div>
- </a-form-model-item>
- <a-form-model-item label="特价规则" prop="discountType">
- <a-select
- default-value="0"
- v-model="form.discountType"
- placeholder="请选择"
- style="width:60%;"
- size="small"
- @change="handleDiscountType"
- allowClear>
- <a-select-option value="0">
- 手动输入特价
- </a-select-option>
- <a-select-option value="1">
- 各级别价打折
- </a-select-option>
- <a-select-option value="2">
- 各级别价直降
- </a-select-option>
- </a-select>
- <a-table
- v-show="form.discountType!=0"
- class="sTable"
- ref="setTable"
- size="small"
- :rowKey="(record) => record.id"
- :columns="setColumns"
- :dataSource="setTableData"
- :pagination="false"
- style="width:60%;"
- bordered>
- <template slot="provinceDiscount" slot-scope="text, record">
- <a-input-number
- size="small"
- v-model="record.provinceValue"
- :min="0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"/>%
- </template>
- <template slot="cityDiscount" slot-scope="text, record">
- <a-input-number
- size="small"
- v-model="record.cityValue"
- :min="record.provinceValue||0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"/>%
- </template>
- <template slot="specialDiscount" slot-scope="text, record">
- <a-input-number
- size="small"
- v-model="record.specialValue"
- :min="record.cityValue ||0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"/>%
- </template>
- <template slot="provincePrice" slot-scope="text, record">
- <a-input-number
- size="small"
- :value="record.provinceValue"
- :min="0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"
- @blur="handleProvincePrice"/>
- </template>
- <template slot="cityPrice" slot-scope="text, record">
- <a-input-number
- size="small"
- :value="record.cityValue"
- :min="0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"
- @blur="handleCityPrice"/>
- </template>
- <template slot="specialPrice" slot-scope="text, record">
- <a-input-number
- size="small"
- :value="record.specialValue"
- :min="0"
- :step="1"
- :precision="2"
- :max="999999"
- placeholder="请输入"
- @blur="handleSpecialPrice"/>
- </template>
- </a-table>
- </a-form-model-item>
- </a-form-model>
- <a-card size="small" :bordered="false" class="pages-wrap">
- <div class="flex" style="margin-bottom:10px;">
- <a-radio-group v-model="chooseVal" button-style="solid">
- <a-radio-button value="a" v-show="form.gateFlag==='1'">
- 门槛产品
- </a-radio-button>
- <a-radio-button value="d">
- 特价产品
- </a-radio-button>
- </a-radio-group>
- <div>
- <a-button
- size="small"
- type="link"
- class="button-info"
- id="promotionList-edit-btn"
- @click="openGuideModal=true"
- >+导入产品</a-button>
- <a-button
- v-show="chooseVal==='d'"
- style="margin-left:10px;"
- size="small"
- type="link"
- class="button-error"
- id="promotionList-edit-btn"
- @click="addProducts">+新增产品</a-button>
- </div>
- </div>
- <div v-show="chooseVal=='a'"><tableType1 :unitTypeList="unitTypeDataList" ref="cillProduct"></tableType1></div>
- <div v-show="chooseVal=='d'"><tableType3 :setData="setTableData" :rulesType="form.discountType" :unitTypeList="unitTypeDataList" ref="specialProduct"></tableType3></div>
- </a-card>
- <div class="btn-cont">
- <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
- <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
- </div>
- </a-spin>
-
- <chooseProductsModal
- type="dealership"
- ref="productBox"
- :openModal="openProductsModal"
- :chooseData="chooseProducts"
- @close="openProductsModal=false"
- @ok="handleProductsAdd" />
-
- <importGuideModal :goodFlag="chooseVal=='a'?'1':'0'" :rulesType="form.discountType" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import tableType1 from './tableType1.vue'
- import tableType3 from './tableType3.vue'
- import { promotionSave, getRuleDetail } from '@/api/promotion'
- import chooseProductsModal from './chooseProductsModal.vue'
- import ImportGuideModal from './importGuideModal.vue'
- import { getLookUpData } from '@/api/data'
- export default {
- name: 'PromotionListBasicInfoModal',
- mixins: [commonMixin],
- components: { VSelect, tableType1, tableType3, chooseProductsModal, ImportGuideModal },
- props: {
- openModal: {
- type: Boolean,
- default: false
- },
- promotionSn: {
- type: [Number, String],
- default: ''
- },
- itemSn: {
- type: [Number, String],
- default: ''
- }
- },
- data () {
- return {
- isShow: this.openModal,
- spinning: false,
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 17 }
- },
- form: {
- promotionRuleType: 'PROMO_PROD',
- description: '',
- gateFlag: '0',
- gateType: undefined,
- gateValue: undefined,
- gateUnit: 'GE',
- quotaUnit: undefined,
- quotaAmount: undefined,
- discountType: '0',
- gateInfo: undefined,
- ruleInfo: undefined
- },
- rules: {
- description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
- gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
- discountType: [{ required: true, message: '请选择特价规则', trigger: 'change' }]
- },
- setTableData: null,
- chooseVal: 'a',
- openProductsModal: false,
- chooseProducts: [],
- openGuideModal: false,
- code: 'SCOPE_UNIT_TYPE',
- unitTypeDataList: []
- }
- },
- computed: {
- setColumns () {
- const _this = this
- var arr = []
- if (_this.form.discountType === '1') {
- arr = [
- { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '33%', align: 'center' },
- { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '33%', align: 'center' },
- { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '33%', align: 'center' }
- ]
- } else if (_this.form.discountType === '2') {
- arr = [
- { title: '省价直降', scopedSlots: { customRender: 'provincePrice' }, width: '33%', align: 'center' },
- { title: '市价直降', scopedSlots: { customRender: 'cityPrice' }, width: '33%', align: 'center' },
- { title: '特约直降', scopedSlots: { customRender: 'specialPrice' }, width: '33%', align: 'center' }
- ]
- }
- return arr
- }
- },
- methods: {
-
- handleUnit (val) {
- this.form.gateUnit = val
- this.form.gateValue = undefined
- },
- handleProvincePrice (e) {
- this.setTableData[0].provinceValue = Number(e.target.value)
- },
- handleCityPrice (e) {
- this.setTableData[0].cityValue = Number(e.target.value)
- },
- handleSpecialPrice (e) {
- this.setTableData[0].specialValue = Number(e.target.value)
- },
-
- handleDiscountType (val) {
- this.form.discountType = val
- this.$refs.specialProduct.reSetTableData()
- this.setTableData = [{
- provinceValue: undefined,
- cityValue: undefined,
- specialValue: undefined
- }]
- },
-
- closeGuideModel () {
- this.openGuideModal = false
- },
-
- handleChange (e) {
- if (e.target.value == '1') {
- this.chooseVal = 'a'
- } else {
- this.chooseVal = 'd'
- this.form.gateType = undefined
- this.form.gateValue = undefined
- this.form.quotaAmount = undefined
- }
- },
- changeGateTypeFlag (val) {
- this.form.gateType = val
- this.form.gateValue = undefined
- this.form.quotaAmount = undefined
- },
-
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
-
- if (_this.form.gateFlag === '1') {
- if (!_this.form.gateType) {
- _this.$message.warning('请选择规则门槛设置类型!')
- return
- }
- if (!_this.form.gateValue) {
- _this.$message.warning('规则门槛条件不能为空!')
- return
- }
- if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
- _this.$message.warning('规则门槛条件不能为空!')
- return
- }
- }
-
- if (_this.form.discountType != '0' && _this.setTableData) {
- if (_this.setTableData[0].provinceValue == undefined || _this.setTableData[0].cityValue == undefined || _this.setTableData[0].specialValue == undefined) {
- _this.$message.warning('特价规则条件不能为空!')
- return
- }
- }
- const form = JSON.parse(JSON.stringify(_this.form))
- if (form.gateFlag === '1') {
- form.gateProductList = _this.$refs.cillProduct.getResultVal()
- form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
- if (form.gateProductList.length == 0) {
- _this.$message.warning('请添加门槛产品!')
- return
- } else {
- const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
- if (qtyFlag) {
- _this.$message.warning('订单起订量设置不能为空!')
- return
- }
- const rowFlag = _this.isJudge(form.gateProductList)
- if (rowFlag) {
- _this.$message.warning('请选择产品分类、品牌或产品!')
- return
- }
- }
- form.gateUnit = form.gateType == 'RATIO_AMOUNT' ? 'RATIO' : form.gateType == 'MIN_AMOUNT' ? 'YUAN' : form.gateUnit
- form.quotaUnit = 'GE'
- } else {
- form.gateProductList = []
- form.gateValue = ''
- form.quotaAmount = ''
- form.gateType = undefined
- form.gateUnit = 'GE'
- form.quotaUnit = undefined
- }
- form.specialProductList = _this.$refs.specialProduct.getResultVal()
- if (form.specialProductList.length == 0) {
- _this.$message.warning('请添加特价产品!')
- return
- } else {
-
- const isTypeEmpty = form.specialProductList.some(item => (item.productTypeList && item.productTypeList.length == 0) && (item.productBrandList && item.productBrandList.length == 0))
- if (isTypeEmpty) {
- _this.$message.warning('产品分类或品牌不能为空!')
- return
- }
- const isNumEmpty = form.specialProductList.some(item => (!item.unitType || !item.unitQty))
- if (isNumEmpty) {
- _this.$message.warning('订单起订量设置不能为空!')
- return
- }
- }
- if (form.discountType === '0') {
- const isCountEmpty = _this.isNumEmpty(form.specialProductList)
- if (isCountEmpty.flag) {
- _this.$message.warning('折扣不能为空!')
- return
- }
- if (isCountEmpty.flag1) {
- _this.$message.warning('折扣金额不能为空!')
- return
- }
- } else {
-
-
-
-
-
-
-
- form.provinceValue = _this.setTableData[0].provinceValue
- form.cityValue = _this.setTableData[0].cityValue
- form.specialValue = _this.setTableData[0].specialValue
- }
- form.promotionSn = _this.promotionSn
- if (form.gateFlag == '1') {
- if (form.gateType === 'RATIO_AMOUNT') {
- form.gateInfo = '购买门槛产品金额' + form.gateValue + '作为配额'
- } else if (form.gateType === 'MIN_AMOUNT') {
- form.gateInfo = '购买门槛产品满最低金额' + form.gateValue + '不限制配额'
- } else {
- form.gateInfo = '购买每满' + form.gateValue + form.gateUnit == 'YUAN' ? '元' : '个' + '门槛产品,可采购' + form.quotaAmount + '个特价产品(配额算销售额)'
- }
- }
- if (form.discountType == '0') {
- form.ruleInfo = '手动输入特价'
- } else if (form.discountType == '1') {
- form.ruleInfo = '各级别价打折;省级折扣' + form.provinceValue + '%,市级折扣' + form.cityValue + '%,特约折扣' + form.specialValue + '%'
- } else {
- form.ruleInfo = '各级别价直降;省级直降' + form.provinceValue + ',市级直降' + form.cityValue + ',特约直降' + form.specialValue
- }
- _this.spinning = true
- promotionSave(form).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- setTimeout(() => {
- _this.isShow = false
- _this.$emit('ok')
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- },
- isNumEmpty (dataList) {
- const arr = []
- const arr1 = []
- dataList.forEach(item => {
- if (item.dataSourceOrigin === '0') {
- if (!item.provinceDiscountRate || !item.cityDiscountRate || !item.specialDiscountRate) {
- arr.push(item.productScopeSn)
- }
- } else {
- if (!item.cityDiscountPrice || !item.provinceDiscountPrice || !item.specialDiscountPrice) {
- arr1.push(item.productScopeSn)
- }
- }
- })
- return { flag: arr.length > 0, flag1: arr1.length > 0 }
- },
-
- isJudge (list) {
- const flag = list.some(con => {
- if (con.productThisList) {
- if (con.productThisList.length > 0) {
- return false
- } else {
- if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
- return false
- } else {
- return true
- }
- }
- } else {
- if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
- return false
- } else {
- return true
- }
- }
- })
- return flag
- },
-
- resetSearchForm () {
- this.form = {
- promotionRuleType: 'PROMO_PROD',
- description: '',
- gateFlag: '0',
- gateType: undefined,
- gateValue: undefined,
- gateUnit: 'GE',
- quotaAmount: undefined,
- discountType: '0',
- gateProductList: undefined,
- specialProductList: undefined,
- quotaUnit: undefined
- }
- this.$nextTick(() => {
- this.$refs.ruleForm.resetFields()
- this.$refs.cillProduct.reSetTableData()
- this.$refs.specialProduct.reSetTableData()
- })
- if (this.form.discountType != '0') {
- this.$refs[0].setTable.clearTable()
- }
- this.setTableData = []
- },
-
- getDetail () {
- const _this = this
- getRuleDetail({ sn: this.itemSn }).then(res => {
- if (res.status == 200) {
- this.chooseVal = res.data.gateFlag == '0' ? 'd' : 'a'
- const resultObj = res.data
- if (resultObj.gateFlag === '1') {
- resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
- }
- if (resultObj.discountType != '0') {
- _this.setTableData = [{
- provinceValue: resultObj.provinceValue,
- cityValue: resultObj.cityValue,
- specialValue: resultObj.specialValue
- }]
- }
-
- if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
- resultObj.gateProductList = _this.newData(resultObj.gateProductList)
- this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
- }
- if (resultObj.specialProductList && resultObj.specialProductList.length > 0) {
- resultObj.specialProductList = _this.newData(resultObj.specialProductList)
- this.$refs.specialProduct.setSourceData(resultObj.specialProductList)
- }
- this.form = { ...this.form, ...resultObj }
- }
- })
- },
- newData (list) {
- list.forEach(con => {
-
- if (con.productBrandList) {
- const brandList = []
- con.productBrandList.forEach(item => {
- item.brandName = item.productBrandName
- const brandObj = {
- productBrandSn: item.productBrandSn
- }
- brandList.push(brandObj)
- })
- con.productBrandArr = con.productBrandList
- con.productBrandList = brandList
- }
-
- if (con.productTypeList) {
- const typeList = []
- con.productTypeList.forEach(item => {
- const typeObj = {}
- item.title = ''
- const num = 3
- for (var i = 0; i < num; i++) {
- if (item['productTypeName' + (i + 1)]) {
- typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
- }
- }
- if (item.productTypeName3) {
- item.title = item.productTypeName2 + '/' + item.productTypeName3
- } else if (!item.productTypeName3 && item.productTypeName2) {
- item.title = item.productTypeName2
- } else {
- item.title = item.productTypeName1
- }
- item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
- typeList.push(typeObj)
- })
- con.productTypeArr = con.productTypeList
- con.productTypeList = typeList
- }
-
- if (con.productThisList) {
- const productList = []
- con.productThisList.forEach(item => {
- const productObj = {
- productCode: item.productCode,
- productSn: item.productSn
- }
- productList.push(productObj)
- })
- con.productThisList = productList
- }
- })
- return list
- },
-
- hanldeOk (arr) {
-
- const resultArr = []
- if (this.chooseVal == 'a') {
- const name = this.chooseVal == 'a' ? 'cill' : this.chooseVal == 'b' ? 'normalPrice' : 'offer'
- this.$refs[name + 'Product'].importRow(arr)
- } else {
-
- const dataList = this.setShowData('This')
- arr.forEach(item => {
- item = { ...item, ...item.product }
- item.code = item.productCode
- if (this.form.discountType == '0') {
- if (item.provincePrice) {
- item.provinceDiscountRate = Math.floor(((item.provinceDiscountPriceText / item.provincePrice) * 100).toFixed(2))
- }
- if (item.cityPrice) {
- item.cityDiscountRate = Math.floor(((item.cityDiscountPriceText / item.cityPrice) * 100).toFixed(2))
- }
- if (item.specialPrice) {
- item.specialDiscountRate = Math.floor(((item.specialDiscountPriceText / item.specialPrice) * 100).toFixed(2))
- }
- } else if (this.form.discountType == '1') {
- if (item.provincePrice) {
- item.provinceDiscountRate = this.form.provinceValue
- item.provinceDiscountPriceText = (item.provincePrice * this.form.provinceValue / 100).toFixed(2)
- }
- if (item.cityPrice) {
- item.cityDiscountRate = this.form.cityValue
- item.cityDiscountPriceText = (item.cityPrice * this.form.cityValue / 100).toFixed(2)
- }
- if (item.specialPrice) {
- item.specialDiscountRate = this.form.specialValue
- item.specialDiscountPriceText = (item.specialPrice * this.form.specialValue / 100).toFixed(2)
- }
- } else {
- if (item.provincePrice) {
- item.provinceSubtract = item.provincePrice - this.form.provinceValue
- }
- if (item.cityPrice) {
- item.citySubtract = item.cityPrice - this.form.cityValue
- }
- if (item.specialPrice) {
- item.specialSubtract = item.specialPrice - this.form.specialValue
- }
- }
- const flag = dataList.includes(item.productSn)
- if (!flag) {
- resultArr.push(item)
- }
- })
- if (resultArr.length > 0) {
- this.handleProductsOk(resultArr)
- } else {
- this.$message.warning('请勿添加重复数据!')
- }
- }
- },
-
- addProducts () {
- this.chooseProducts = []
- this.openProductsModal = true
- const dataList = this.setShowData('This')
- this.$refs.productBox.handleDisabled(dataList)
- },
-
- setShowData (name) {
- const _this = this
- const snArr = []
- const valList = _this.$refs.specialProduct.getResultVal()
- valList.forEach(item => {
- if (item['product' + name + 'List'] && item['product' + name + 'List'].length > 0) {
- item['product' + name + 'List'].forEach(con => {
- const newName = name === 'This' ? '' : name
- snArr.push(con['product' + newName + 'Sn'])
- })
- }
- })
- return snArr
- },
- handleProductsAdd (con) {
- const newArr = []
- const newConArr = []
- con.forEach(newCon => {
- if (!newCon.provincePrice || !newCon.cityPrice || !newCon.specialPrice) {
- newArr.push(newCon.code)
- }
- })
- con.forEach((list, pos) => {
- if (list.provincePrice && list.cityPrice && list.specialPrice) {
- newConArr.push(list)
- }
- })
- const _this = this
- if (newArr && newArr.length > 0) {
- _this.$info({
- title: '提示',
- content: newArr.toString() + '(产品编码),没有定价,不可添加',
- closable: true,
- centered: true,
- onOk () {
- _this.handleProductsOk(newConArr)
- }
- })
- } else {
- _this.handleProductsOk(newConArr)
- }
- },
-
- generateUniqueRandomNumber () {
- const timestamp = new Date().getTime()
- const randomNumber = Math.floor(Math.random() * 1e5).toString().padStart(5, '0')
- const uniqueRandomNumber = timestamp + randomNumber
- return uniqueRandomNumber
- },
-
- handleProductsOk (con) {
- const _this = this
- _this.spinning = true
- setTimeout(() => {
- _this.spinning = false
- }, 1500)
- con.forEach(async (item) => {
- const chooseProductsList = []
- const getSn = this.generateUniqueRandomNumber()
- if (getSn) {
- const newData = {
- productScopeSn: getSn,
- dataSourceOrigin: '1',
- productTypeArr: [],
- productTypeList: [],
- productBrandArr: [{ productBrandSn: item.productBrandSn, brandName: item.productBrandName }],
- productBrandList: [{ productBrandSn: item.productBrandSn }],
- productThisList: [{
- productSn: item.productSn,
- productCode: item.code
- }],
- provincePrice: item.provincePrice,
- cityPrice: item.cityPrice,
- specialPrice: item.specialPrice,
- provinceDiscountPrice: item.provinceDiscountPriceText,
- cityDiscountPrice: item.cityDiscountPriceText,
- specialDiscountPrice: item.specialDiscountPriceText,
- unitType: item.unitType || 'SL',
- unitQty: item.unitQty || '1',
- provinceDiscountRate: item.provinceDiscountRate ? item.provinceDiscountRate : undefined,
- cityDiscountRate: item.cityDiscountRate ? item.cityDiscountRate : undefined,
- specialDiscountRate: item.specialDiscountRate ? item.specialDiscountRate : undefined
- }
- const obj = {}
- if (item.productTypeSn1) {
- obj.productTypeSn1 = item.productTypeSn1
- }
- if (item.productTypeSn2) {
- obj.productTypeSn2 = item.productTypeSn2
- }
- if (item.productTypeSn3) {
- obj.productTypeSn3 = item.productTypeSn3
- }
- const newObj = { ...obj, ...{} }
- if (Object.keys(obj).length == 1) {
- newObj.title = item.productTypeName1
- newObj.id = item.productTypeSn1
- } else if (Object.keys(obj).length == 2) {
- newObj.title = item.productTypeName2
- newObj.id = item.productTypeSn2
- } else {
- newObj.title = item.productTypeName2 + '/' + item.productTypeName3
- newObj.id = item.productTypeSn3
- }
- newData.productTypeList[0] = obj
- newData.productTypeArr[0] = newObj
- chooseProductsList.push(newData)
- }
- _this.$refs.specialProduct.setSourceData(chooseProductsList)
- })
- },
- getUnitTypeList () {
- const _this = this
- getLookUpData({
- pageNo: 1,
- pageSize: 1000,
- lookupCode: _this.code
- }).then(res => {
- if (res.status == 200) {
- _this.unitTypeDataList = res.data.list
- }
- })
- }
- },
- watch: {
-
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
-
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetSearchForm()
- } else {
-
- this.getUnitTypeList()
- if (this.itemSn) {
- this.getDetail()
- } else {
- this.chooseVal = this.form.gateFlag == '0' ? 'd' : 'a'
- }
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- // .ant-modal-confirm-body{
- // max-height: 500px;
- // overflow-y:scroll;
- // }
- .promotionList-basicInfo-modal{
- /deep/.ant-modal-body {
- padding: 20px 30px;
- max-height: 745px !important;
- overflow-y: scroll !important;
- }
- .ant-radio-button-wrapper{
- width:80px;
- text-align: center;
- }
- .ant-form-item{
- margin-bottom:5px;
- }
- .buyerBox{
- border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
- }
- .btn-cont {
- text-align: center;
- margin: 20px 0 10px;
- }
- .flex{
- display:flex;
- align-items:center;
- justify-content:space-between;
- }
- }
- /deep/.ve-table{
- border-radius:5px;
- }
- </style>
|