1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090 |
- <template>
- <div>
- <div class="app-container mymain-container" v-show="isCondition == 0">
- <el-header height="50px" class="header">
- <el-page-header
- content="编辑"
- @back="($parent.isShow = 1), ($parent.isFlag = '')"
- />
- </el-header>
- <div >
- <div class="screen-container">
- <h4>销售政策信息</h4>
- <el-divider />
- <el-form
- ref="form"
- :model="searchForm"
- label-width="120px"
- size="mini"
- class="demo-searchForm"
- >
- <el-row>
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="销售政策编号">
- <el-input
- v-model="searchForm.code"
- disabled
- placeholder="如未填写,则系统自动生成"
- />
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="销售政策名称" prop="title">
- <el-input
- v-model="searchForm.title"
- placeholder="销售政策名称"
- />
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="销售政策类型" prop="type">
- <el-select
- v-model="searchForm.type"
- size="mini"
- placeholder="销售政策类型"
- class="select_height"
- >
- <el-option
- v-for="(item, index) in typeOptions"
- :key="index"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="" prop="type">
- <div style="height: 30px">
- <el-checkbox v-model="searchForm.isFullRebate">返利使用金额需满额使用</el-checkbox>
- </div>
- </el-form-item>
- </el-col>
- <!-- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="产品类别" prop="mainId">
- <el-select
- v-model="searchForm.mainId"
- :disabled="dataList.length ? true : false"
- placeholder="请选择"
- @change="handelStop"
- >
- <el-option
- v-for="item in dictList"
- :label="item.dictValue"
- :value="item.dictCode"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col> -->
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="生效日期" prop="startTime">
- <el-date-picker
- v-model="searchForm.startTime"
- type="datetime"
- placeholder="生效日期"
- default-time="00:00:00"
- value-format="yyyy-MM-dd HH:mm:ss"
- /> </el-form-item></el-col>
- <el-col :xs="24" :ms="12" :lg="12">
- <el-form-item label="失效日期" prop="endTime">
- <el-date-picker
- v-model="searchForm.endTime"
- type="datetime"
- placeholder="失效日期"
- default-time="00:00:00"
- value-format="yyyy-MM-dd HH:mm:ss"
- /> </el-form-item></el-col>
- <el-col :xs="24" :ms="24" :lg="24">
- <el-form-item label="表头备注" prop="remark">
- <el-input
- v-model="searchForm.remark"
- placeholder="新风机变频挂机。按提货数量1:3开单"
- />
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="24" :lg="24">
- <el-form-item label="政策封面图">
- <ImageUpload :file-list="fileList" :multiple="false" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div class="mymian-container">
- <el-row>
- <el-divider />
- <el-row type="flex">
- <el-col :span="12">
- <h4 style="display: inline-block; margin-right: 20px">
- 货品信息
- </h4>
- <template>
- <el-upload
- class="import-btn"
- :action="baseURL + 'student/import'"
- :http-request="handleImport"
- :file-list="importFileList"
- :show-file-list="false"
- >
- <el-button
- type="primary"
- size="mini"
- >导入货品价格表</el-button>
- </el-upload>
- </template>
- <el-button
- type="primary"
- size="mini"
- @click="hanleDownloadFiles"
- >下载模板</el-button>
- </el-col>
- </el-row>
- <el-divider />
- </el-row>
- <div class="table">
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- max-height="600"
- border
- fit
- highlight-current-row
- stripe
- >
- <el-table-column
- type="index"
- label="序号"
- width="50"
- align="left"
- />
- <el-table-column
- min-width="200"
- prop="materialNumber"
- label="物料编码"
- align="left"
- >
- <template slot-scope="scope">
- <CopyButton :copyText="scope.row.materialNumber" />
- <el-select
- v-model="scope.row.materialNumber"
- v-el-select-loadmore="loadmore"
- size="mini"
- :remote-method="(query)=>remoteMethod(query,'number')"
- filterable
- remote
- style="width: 85%;"
- @change="handleK3List($event, scope.row)"
- >
- <el-option
- v-for="item in k3List"
- :key="item.id"
- :label="item.number"
- :value="item.id"
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- show-overflow-tooltip
- min-width="150"
- prop="materialName"
- label="产品名称"
- align="left"
- >
- <template slot-scope="scope">
- <CopyButton :copyText="scope.row.materialName" />
- <span>{{scope.row.materialName}}</span>
- </template>
- </el-table-column>
- <el-table-column
- min-width="300"
- prop="specification"
- label="规格型号"
- align="left"
- >
- <template slot-scope="scope" >
- <CopyButton :copyText="scope.row.specification" />
- <el-select
- v-model="scope.row.specification"
- size="mini"
- :remote-method="(query)=>remoteMethod(query,'specification')"
- filterable
- remote
- style="width: 85%;"
- @change="handleK3List($event, scope.row)"
- >
- <el-option
- v-for="item in k3List"
- :key="item.id"
- :label="item.specification"
- :value="item.id"
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- show-overflow-tooltip
- min-width="150"
- prop="saleTypeName"
- label="销售类型"
- align="left"
- >
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.saleTypeId"
- size="mini"
- filterable
- @change="handleSalesType($event, scope.row)"
- >
- <el-option
- v-for="item in typeList"
- :key="item.id"
- :label="item.saleName"
- :value="item.id"
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- show-overflow-tooltip
- min-width="150"
- prop="saleTypeCode"
- label="销售类型编码"
- align="left"
- />
- <el-table-column prop="discAmount" label="格力折扣" align="right">
- <template slot-scope="scope">
- <el-input
- size="mini"
- class="yinput"
- v-model.number="scope.row.discAmount"
- type="number" @mousewheel.native.prevent
- placeholder="请输入格力折扣"
- />
- </template>
- </el-table-column>
- <el-table-column prop="price" label="单价" align="right" show-overflow-tooltip
- min-width="150">
- <template slot-scope="scope">
- <el-input
- class="yinput"
- v-model.number="scope.row.price"
- type="number" @mousewheel.native.prevent
- placeholder="请输入单价"
- size="mini"
- />
- </template>
- </el-table-column>
- <el-table-column label="返利钱包" align="left" show-overflow-tooltip
- min-width="150">
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.rebateWalletIds"
- size="mini"
- multiple
- filterable
- >
- <el-option
- v-for="item in rebateList"
- :key="item.walletRebateId"
- :label="item.name"
- :value="item.walletRebateId"
- />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="现金钱包" align="left" show-overflow-tooltip
- min-width="150">
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.walletIds"
- size="mini"
- multiple
- filterable
- >
- <el-option
- v-for="item in NoRebateWalletList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- <!-- <el-tag
- style="margin: 5px"
- type="success"
- size="mini"
- v-for="item in scope.row.walletRelaList"
- >{{ item.walletName }}</el-tag
- > -->
- </template>
- </el-table-column>
- <el-table-column prop="remark" label="备注" align="left" show-overflow-tooltip
- min-width="150">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.remark"
- placeholder="备注"
- size="mini"
- />
- </template>
- </el-table-column>
- <el-table-column fixed="right" label="操作" align="center">
- <template slot-scope="scope">
- <el-popconfirm
- confirm-button-text="好的"
- cancel-button-text="不用了"
- icon="el-icon-info"
- icon-color="red"
- title="内容确定删除吗?"
- @onConfirm="hanleDelete(scope.row.id, scope.$index)"
- >
- <el-button
- slot="reference"
- type="text"
- class="textColor el-popover-left"
- >删除</el-button>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页 -->
- <div
- style="
- margin: 20px 20px 20px 0;
- display: flex;
- justify-content: space-between;
- "
- >
- <div>
- <el-button
- type="primary"
- size="mini"
- @click="handleNewInfo"
- >添加</el-button>
- <el-button
- type="primary"
- size="mini"
- @click="handleSave"
- >保存</el-button>
- </div>
- <!-- <el-pagination-->
- <!-- :current-page="dcurrentPage"-->
- <!-- :page-sizes="pageSizeArr"-->
- <!-- :page-size="size"-->
- <!-- layout="total, sizes, prev, pager, next, jumper"-->
- <!-- :total="listTotal"-->
- <!-- @size-change="handleSizeChange2"-->
- <!-- @current-change="handleCurrentChange2"-->
- <!-- />-->
- </div>
- <el-row>
- <el-divider />
- <el-row type="flex">
- <el-col :span="12">
- <h4 style="display: inline-block; margin-right: 20px">
- 条件信息
- </h4>
- <el-button
- type="primary"
- size="mini"
- @click="handleAddCondition"
- >添加</el-button></el-col>
- </el-row>
- <el-divider />
- </el-row>
- <el-table
- :data="conditionList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- >
- <el-table-column
- fixed
- type="index"
- label="序号"
- width="50"
- align="left"
- />
- <el-table-column prop="name" label="限定条件" align="left">
- <template slot-scope="scope">
- <el-input
- size="mini"
- v-model="scope.row.name"
- style="text-align: center"
- placeholder="请输入名称"
- :disabled="scope.row.fang"
- @blur="handleConditionName(scope.row)"
- />
- </template>
- </el-table-column>
- <el-table-column
- fixed="right"
- width="150"
- label="操作"
- align="center"
- >
- <template slot-scope="scope">
- <el-button
- type="text"
- size="mini"
- @click="scope.row.fang = false; conditName=scope.row.name"
- >编辑</el-button>
- <el-button
- type="text"
- size="mini"
- @click="handleCondition(scope.row.id, scope.$index)"
- >删除</el-button>
- <el-button
- type="text"
- size="mini"
- @click="
- catCond(scope.row)
- "
- >查看条件</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div>
- <el-row>
- <el-divider />
- <el-row type="flex" align="middle">
- <el-col :span="2">
- <h4>经销商信息</h4>
- </el-col>
- </el-row>
- <el-divider />
- </el-row>
- <TabelTransfer v-if="detail && detail.code" :code="detail.code" :yregion="region" @handlEditPolicy="handlEditPolicy" @handleReset="handleReset" />
- </div>
- </div>
- </div>
- <AddCondition
- ref="comDom"
- v-show="isCondition === 1"
- @handleSubmitCon="handleSubmitCon"
- />
- <AddCondition ref="cond" v-show="isCondition === 2" :id="cid" />
- </div>
- </template>
- <script>
- import { mapGetters, mapMutations } from 'vuex'
- import Minxin from '@/mixin'
- import {
- deleteCondition,
- deleteMaterialPolicy,
- getConditionList,
- getK3List,
- getMaterialList,
- getNoRebateWalletList,
- getPolicyDetail,
- getTypeList,
- getWalletRebateList,
- savePolicy,
- updateCondition,
- updatePolicy,
- getConditionMaterialDetail
- } from '@/api/policy_list'
- import { downloadFiles, handleImport } from '@/utils/util'
- // import Transfer from './Transfer'
- import TabelTransfer from './TabelTransfer'
- import AddCondition from './AddCondition'
- import EditCondition from './EditCondition'
- import ImageUpload from '@/components/Common/image-upload.vue'
- export default {
- directives: {
- 'el-select-loadmore': {
- bind(el, binding) {
- // 获取element-ui定义好的scroll盒⼦
- const SELECTWRAP_DOM = el.querySelector(
- '.el-select-dropdown .el-select-dropdown__wrap'
- )
- SELECTWRAP_DOM.addEventListener('scroll', function() {
- /**
- * scrollHeight 获取元素内容⾼度(只读)
- * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
- * clientHeight 读取元素的可见⾼度(只读)
- * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
- * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
- */
- const condition =
- this.scrollHeight - this.scrollTop <= this.clientHeight
- if (condition) {
- binding.value()
- }
- })
- }
- }
- },
- mixins: [Minxin],
- data() {
- return {
- fang: false,
- input: '',
- baseURL: '',
- isCondition: 0,
- searchForm: {
- code: '',
- endTime: '',
- imgSrc: '',
- remark: '',
- startTime: '',
- title: '',
- mainId: '',
- mainName: '',
- type: '',
- isFullRebate: false,
- },
- conditName:'',
- dataList: [],
- addList: [],
- pageSizeArr: [10, 20, 30, 50],
- size: 10,
- listLoading: false,
- dialogVisible: false,
- importFileList: [],
- fileList: [],
- options: {},
- value: '',
- typeList: [],
- walletList: [],
- typeOptions: [
- {
- value: 'PROVISION',
- label: '配提'
- },
- {
- value: 'LIMIT',
- label: '限量'
- }
- ],
- conditionList: [],
- dictList: [],
- k3List: [],
- NoRebateWalletList: [],
- sleectBox: { currentPage: 1 },
- dpageSize: 10,
- dcurrentPage: 1,
- detail: {},
- rebateList: [],
- cid:'',
- cpolicyId:'',
- region:0
- }
- },
- computed: {
- ...mapGetters({
- comCode: 'code'
- })
- },
- created() {
- this.getCommonApi()
- // console.log(this.$store.code);
- if (this.$parent.isFlag) {
- // this.handletwoList()
- }
- },
- methods: {
- ...mapMutations('sales', ['initData']),
- // 下载excel模板
- hanleDownloadFiles() {
- downloadFiles('policy/download')
- },
- handleCondition(id, index) {
- deleteCondition({ id }).then((res) => {
- this.conditionList.splice(index, 1)
- Object.assign(
- this.$children[9].$data,
- this.$children[9].$options.data()
- )
- this.$successMsg('删除成功')
- })
- },
- catCond(row){
- this.cid = row.id
- this.$refs.cond.getCommonApi()
- this.isCondition = 2
- // $refs.cond.getCommonApi(),
- // (), (cid = scope.row.id)
- },
- handleAddCondition() {
- this.isCondition = 1
- console.log(this.conditionList[0].id,this.searchForm.code);
- this.$refs.comDom.getCommonApi(this.conditionList[0].id)
- this.$store.commit('sales/setId', this.searchForm.code)
- },
- loadmore() {
- this.sleectBox.currentPage++
- this.getK3List()
- },
- getK3List() {
- getK3List({
- pageNum: this.sleectBox.currentPage,
- pageSize: 10,
- keyword: ''
- }).then((res) => {
- this.k3List = [...this.k3List, ...res.data.records]
- })
- },
- remoteMethod(query, type) {
- console.log(query, type)
- if (query !== '') {
- getK3List({
- pageNum: 1,
- pageSize: 100,
- keyword: '',
- number: type === 'number' ? query : '',
- oldNumber: '',
- specification: type === 'specification' ? query : ''
- }).then((res) => {
- this.k3List = res.data.records
- })
- } else {
- this.sleectBox.currentPage = 1
- this.getK3List()
- }
- },
- getCommonApi() {
- this.getK3List()
- // 非返利钱包
- getNoRebateWalletList({ walletName: '' }).then((res) => {
- this.NoRebateWalletList = res.data
- console.log(this.NoRebateWalletList, 'kkkk')
- })
- getWalletRebateList({
- pageNum: 1,
- pageSize: -2,
- name: '',
- status: true
- }).then(res => {
- this.rebateList = res.data.records
- console.log(this.rebateList, 'fanlie')
- })
- const params = {
- pageNum: 1,
- pageSize: -1,
- saleCode: '',
- saleName: '',
- status: ''
- }
- // 获取销售类型列表
- getTypeList(params).then((res) => {
- this.typeList = res.data.records
- })
- // this.handletwoList()
- // const params = {
- // pageNum: 1,
- // pageSize: 10,
- // saleCode: "",
- // saleName: "",
- // status: "",
- // };
- // const walletParams = {
- // pageNum: 1,
- // pageSize: 10,
- // mainName: "",
- // saleTypeCode: "",
- // saleTypeName: "",
- // status: "",
- // };
- // // 获取钱包列表
- // getWalletList(walletParams).then((res) => {
- // this.walletList = res.data.records;
- // });
- // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
- // this.dictList = res.data;
- // });
- },
- handleSalesType(e, row) {
- const item = this.typeList.filter((k) => {
- return k.id === e
- })[0]
- const linshi = []
- const rebateList = []
- this.rebateList.forEach((k) => {
- k.saleTypes.forEach((j) => {
- if (!linshi.includes(j.saleTypeId) && j.saleTypeId == e) {
- rebateList.push(k)
- linshi.push(j.saleTypeId)
- }
- })
- })
- if (rebateList.length) {
- this.$set(row, 'rebateWalletIds', [...new Set([...row.rebateWalletIds, rebateList[0].walletRebateId])])
- }
- this.$set(row, 'saleTypeCode', item.saleCode)
- this.$set(row, 'saleTypeName', item.saleName)
- // this.$set(row,'saleTypeId',item.id)
- },
- // 修改条件名称
- handleConditionName(row) {
- console.log(row.name)
- if (this.conditName !== row.name){
- updateCondition({ id: row.id, name: row.name }).then((res) => {
- this.$successMsg('修改成功')
- })
- }
- row.fang = true
- },
- // 提交信息
- handleSubmitCon() {
- const params = {
- policyId: this.searchForm.code
- }
- // 获取条件政策
- getConditionList(params).then((res) => {
- for (let i = 0; i < res.data.length; i++) {
- res.data[i].fang = true
- }
- this.conditionList = res.data
- Object.assign( this.$refs.comDom.$data,this.$refs.comDom.$options.data())
- })
- },
- // 视图部分已注释,废弃的功能 fucn
- handelStop() {
- if (this.searchForm.mainId) {
- this.fang = true
- } else {
- this.$errorMsg('请选择产品类别')
- }
- },
- // 导入
- async handleImport(param) {
- this.importLoading = true
- const file = param.file
- console.log(file, 123)
- const formData = new FormData()
- formData.append('file', file)
- formData.append('policyId', this.searchForm.code)
- // formData.append("mainId", this.searchForm.mainId);
- const result = await handleImport('/policy/material/import', formData)
- this.importLoading = false
- this.importFileList = []
- if (result.code === 200) {
- this.$alert(result.message, '导入成功', {
- confirmButtonText: '确定'
- })
- this.dataList = []
- this.listTotal = 0
- this.sleectBox.currentPage = 1
- this.handletwoList()
- } else {
- this.$alert(result.message, '导入失败', {
- confirmButtonText: '确定'
- })
- }
- },
- getList() {
- getPolicyDetail({ policyId: this.$parent.id }).then((res) => {
- this.detail = res.data
- this.searchForm = {
- code: this.detail.code,
- endTime: this.detail.endTime,
- imgSrc: this.detail.imgSrc,
- remark: this.detail.remark,
- startTime: this.detail.startTime,
- title: this.detail.title,
- type: this.detail.type
- },
- this.region = res.data.flag
- this.srcList = [this.$imageUrl + this.detail.imgSrc]
- if (this.$parent.isShow === 5 && this.detail.imgSrc) {
- this.fileList = [
- {
- hover: '',
- url: this.detail.imgSrc
- }
- ]
- }
- this.handletwoList()
- // 获取条件政策
- this.handleSubmitCon()
- })
- if (this.$parent.isFlag) {
- this.handletwoList()
- }
- },
- // 更改每页数量
- handleSizeChange1(val) {
- this.pageSize = val
- this.currentPage = 1
- this.handletwoList()
- },
- // 更改当前页
- handleCurrentChange1(val) {
- this.currentPage = val
- this.handletwoList()
- },
- // 更改每页数量
- handleSizeChange2(val) {
- this.dpageSize = val
- this.dcurrentPage = 1
- this.handletwoList()
- },
- // 更改当前页
- handleCurrentChange2(val) {
- this.dcurrentPage = val
- this.handletwoList()
- },
- // 获取货品信息
- handletwoList() {
- // this.searchForm.type
- this.listLoading = true
- const paramss = {
- pageNum: this.dcurrentPage,
- pageSize: -1,
- policyId: this.searchForm.code,
- saleTypeCode: ''
- }
- getMaterialList(paramss)
- .then((result) => {
- result.data.records.forEach((k) => {
- k.walletIds = []
- k.rebateWalletIds = []
- if (!k.specification) {
- k.materialNumber = k.materialId
- k.specification = k.materialId
- }
- k.walletRelaList.forEach((l) => {
- l.id = l.walletId
- l.name = l.walletName
- if (l.type === 'REBATE') {
- k.rebateWalletIds = [...k.rebateWalletIds, l.walletId]
- } else {
- k.walletIds = [...k.walletIds, l.walletId]
- }
- })
- })
- // this.dataList=[]
- this.dataList = result.data.records
- this.listTotal = result.data.total
- this.listLoading = false
- })
- .catch((err) => {
- console.error(err)
- })
- },
- // 提交审核
- handlEditPolicy(policyCustomers,region) {
- if (!this.searchForm.title) {
- this.$errorMsg('请输入说明')
- return
- }
- if (!this.searchForm.type) {
- this.$errorMsg('请选择类型')
- return
- }
- if (!this.searchForm.startTime) {
- this.$errorMsg('请选择生效日期')
- return
- }
- const formtData = ()=>{
- var arr = []
- policyCustomers.forEach((el) => {
- arr.push({
- customerId: el.customerId || el.customerId,
- customerName: el.name || el.customerName,
- customerNumber: el.number || el.customerNumber,
- lastOrderTime: '',
- limitTakeNum: 0,
- policyId: this.searchForm.code || this.detail.code,
- policyTitle: '',
- remark: ''
- })
- })
- // this.dictList.forEach((k) => {
- // if (k.dictCode == this.searchForm.mainId) {
- // this.searchForm.mainName = k.dictValue;
- // }
- // });
- const params = {
- ...this.detail,
- ...this.searchForm,
- flag:region,
- endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
- policyCustomers: arr,
- imgSrc: this.fileList.length ? this.fileList[0].url : ''
- }
- console.log(this.fileList)
- updatePolicy(params).then((res) => {
- console.log(res)
- this.$successMsg('编辑成功')
- this.$parent.getList()
- this.$parent.isShow = 1
- })
- }
- if(region ==0){
- if (policyCustomers.length) {
- formtData()
- } else {
- this.$errorMsg('选择经销商 ')
- }
- }else{
- formtData()
- }
- },
- // 删除
- hanleDelete(id, index) {
- if (id) {
- const params = { policyMaterialId: id }
- deleteMaterialPolicy(params).then((res) => {
- this.dataList.splice(index, 1)
- })
- return
- }
- this.dataList.splice(index, 1)
- if (!this.dataList.length) {
- this.dcurrentPage !== 1 ? this.dcurrentPage -= 1 : this.dcurrentPage = 1
- }
- // this.listTotal -= 1;
- this.$successMsg('删除成功')
- },
- handleNewInfo() {
- // 物料列表
- this.dataList.push({
- id: '',
- discAmount: '',
- materialId: '',
- materialName: '',
- materialNumber: '',
- policyId: this.searchForm.code,
- price: '',
- remark: '',
- saleTypeCode: '',
- saleTypeId: '',
- saleTypeName: '',
- specification: '',
- walletIds: [this.NoRebateWalletList[0].id],
- walletRelaList: []
- })
- this.sleectBox.currentPage = 1
- // this.listTotal += 1;
- // this.dataList.push(this.addList[this.addList.length-1])
- },
- handleSave() {
- if (!this.dataList.length) {
- return
- }
- for (let i = 0; i < this.dataList.length; i++) {
- if (!this.dataList[i].materialId) {
- this.$errorMsg('请选择货品')
- return
- }
- if (!this.dataList[i].saleTypeId) {
- this.$errorMsg('请选择销售类型')
- return
- }
- if (!this.dataList[i].price) {
- this.$errorMsg('请输入单价')
- return
- }
- if (!this.dataList[i].walletIds.length) {
- this.$errorMsg('请选择现金钱包')
- return
- }
- }
- savePolicy(this.dataList).then((res) => {
- this.dataList = []
- this.sleectBox.currentPage = 1
- this.dcurrentPage = 1
- this.$successMsg('保存成功')
- this.handletwoList()
- })
- },
- handleK3List(e, row) {
- const item = this.k3List.filter((k) => {
- return k.id == e
- })[0]
- this.$set(row, 'materialNumber', item.number)
- this.$set(row, 'materialName', item.name)
- this.$set(row, 'specification', item.specification)
- this.$set(row, 'materialId', item.id)
- this.getK3List()
- },
- handleReset() {
- Object.assign(this.$data, this.$options.data())
- this.getCommonApi()
- }
- },
- components: {
- // Transfer,
- AddCondition,
- ImageUpload,
- EditCondition,
- TabelTransfer
- }
- }
- </script>
- <style lang="scss" scoped>
- h4 {
- margin: 0;
- }
- .yinput{
- ::v-deep input{
- text-align: right;
- }
- }
- .pdt {
- padding-top: 20px;
- }
- .import-btn {
- margin-right: 10px;
- display: inline-block;
- }
- .radio {
- padding: 20px 0;
- }
- .el-divider--horizontal {
- margin: 20px 0;
- }
- .el-container .el-divider--horizontal {
- margin: 10px;
- }
- .el-select {
- width: 100%;
- }
- .footer {
- margin-bottom: 20px;
- }
- </style>
|