Commit 3a00a5de by chenwq

格式化代码

1 parent a30999f7
<!-- 新增交付数&修改交付数&交付数详情 -->
<template>
<baseDialog :dialog-config="dialogConfig"
:is-show.sync="dialogShow"
<baseDialog class="accountDailog"
:config="config"
class="accountDailog"
:dialog-config="dialogConfig"
:is-show.sync="dialogShow"
@handleClick="handleAddConfirm">
<div class="add-dialog">
<el-form ref="infoForm"
class="infoForm d2-container-content"
label-width="130px"
:model="formData"
:rules="formRules"
label-width="130px">
:rules="formRules">
<el-row>
<el-col :span="12">
<el-form-item label="4S门店:"
:prop="operationType =='add'?'merchantId':''">
<div v-if="operationType =='add'">
:prop="operationType == 'add' ? 'merchantId' : ''">
<div v-if="operationType == 'add'">
<el-select v-model="formData.merchantId"
v-el-select-loadmore="interestsLoadmore"
class="sortInput"
placeholder="请选择"
filterable
remote
reserve-keyword
@visible-change="visibleChange"
@change="choose4S"
:remote-method="remoteMethod"
v-el-select-loadmore="interestsLoadmore"
filterable
class="sortInput">
@change="choose4S"
@visible-change="visibleChange">
<el-option v-for="subItem in baseData.merchantList"
:key="subItem.merchantId"
:label="`${subItem.merchantName}(${subItem.merchantId})`"
......@@ -34,23 +34,23 @@
</el-select>
</div>
<div v-else>
{{ formData.merchantName +'('+ formData.merchantId +')' }}
{{ `${formData.merchantName}(${formData.merchantId})` }}
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="品牌:"
:prop="operationType =='add'?'brand':''">
<div v-if="operationType =='add'">
:prop="operationType == 'add' ? 'brand' : ''">
<div v-if="operationType == 'add'">
<el-cascader ref="cascader"
:options="carBrands"
v-model="formData.brand"
class="sortInput"
placeholder="请先选择4S门店"
filterable
@change="chooseBrand"
clearable
:props="{ label: 'name', value: 'id', children:'subList' }"
class="sortInput">
filterable
:options="carBrands"
:props="{ label: 'name', value: 'id', children: 'subList' }"
@change="chooseBrand">
</el-cascader>
</div>
<div v-else>
......@@ -62,15 +62,15 @@
<el-row>
<el-col :span="12">
<el-form-item label="交付目标月份:"
:prop="operationType =='add'?'targetMonth':''">
<div v-if="operationType =='add'">
:prop="operationType == 'add' ? 'targetMonth' : ''">
<div v-if="operationType == 'add'">
<el-date-picker v-model="formData.targetMonth"
type="month"
value-format="yyyy-MM"
class="sortInput"
format="yyyy-MM"
placeholder="选择月"
type="month"
value-format="yyyy-MM"
:picker-options="pickerOption"
class="sortInput"
@change="handleTargetMonthChange">
</el-date-picker>
</div>
......@@ -81,10 +81,10 @@
</el-col>
<el-col :span="12">
<el-form-item label="归属周期:"
:prop="operationType !='detail'?'periodRange':''">
<div v-if="operationType !='detail'">
<period-date-range v-model="formData.periodRange"
:target-month="formData.targetMonth" />
:prop="operationType != 'detail' ? 'periodRange' : ''">
<div v-if="operationType != 'detail'">
<PeriodDateRange v-model="formData.periodRange"
:target-month="formData.targetMonth" />
</div>
<div v-else>
{{ formData.periodDateStr || '-' }}
......@@ -95,12 +95,12 @@
<el-row>
<el-col :span="12">
<el-form-item label="交付数:"
:prop="operationType !='detail'?'targetValue':''">
<div v-if="operationType !='detail'">
:prop="operationType != 'detail' ? 'targetValue' : ''">
<div v-if="operationType != 'detail'">
<el-input v-model="formData.targetValue"
@input="targetValue_handleInput"
class="sortInput"
placeholder="请输入"
class="sortInput" />
@input="targetValue_handleInput" />
</div>
<div v-else>
{{ formData.targetValue }}
......@@ -108,21 +108,23 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="录入时间:"
v-if="operationType!='add'">
<el-form-item v-if="operationType != 'add'"
label="录入时间:">
{{ formData.createdDateShow }}
</el-form-item>
</el-col>
</el-row>
</el-form>
<div v-if="operationType!='add'">
<div class="div-title">操作记录</div>
<div v-if="operationType != 'add'">
<div class="div-title">
操作记录
</div>
<div class="d2-container-content">
<d2-table ref="recordTable"
:has-page="false"
:has-num="false"
:table-data="tableData"
:has-page="false"
:search-form="searchFormSearch"
:table-data="tableData"
:table-params="tableParams">
</d2-table>
</div>
......@@ -132,366 +134,371 @@
</template>
<script>
import { Util, deepClone } from '@/common/util'
import { limitPrice, rangePickerOptions_deliveryQuantity, getMonthDateRange, parsePeriodDateStr } from '@/common/format'
import { getList } from "@api/merchant"
import { outputValue_operTypeOpt } from "@/common/constants.js"
import { insertDeliverTargeConfig, updateDeliverTargeConfig, getById_deliver, getCarBrand } from '@api/shopConfig'
import periodDateRange from './periodDateRange'
import { getList } from "@api/merchant";
import { getById_deliver, getCarBrand, insertDeliverTargeConfig, updateDeliverTargeConfig } from "@api/shopConfig";
import { outputValue_operTypeOpt } from "@/common/constants.js";
import { getMonthDateRange, limitPrice, parsePeriodDateStr, rangePickerOptions_deliveryQuantity } from "@/common/format";
import { deepClone, Util } from "@/common/util";
import periodDateRange from "./periodDateRange";
// import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
export default {
name: 'EditDialog',
components: {
periodDateRange
},
// mixins: [reportTrackFunMixin],
directives: {
'el-select-loadmore': {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
'.el-select-dropdown .el-select-dropdown__wrap'
)
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition =
this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) {
binding.value()
}
})
}, 100)
}
}
},
data() {
return {
config: {
appendToBody: true,
isShowFooter: true,
confirm_name: '确定',
cancel_name: '取消'
},
pickerOption: rangePickerOptions_deliveryQuantity,
userInfo: this.$store.state.d2admin.user.info,
formData: {
merchantId: '',
merchantName: '',
brand: [],
brandId: '',
brandName: '',
childId: '',
childName: '',
targetValue: '',
targetMonth: '',
periodRange: [],
periodDateStr: ''
},
oldVal: {
targetValue: ''
},
dialogConfig: {
title: '新增交付数',
// width: '700px'
width: '1080px'
},
formRules: {
merchantId: [{ required: true, message: '请选择4S门店', trigger: 'change' }],
brand: [{ required: true, message: '请选择品牌', trigger: 'change' }],
targetMonth: [{ required: true, message: '请选择交付目标月份', trigger: 'change' }],
periodRange: [{
required: true,
trigger: 'change',
validator: (rule, value, callback) => {
if (!value || value.length !== 2 || !value[0] || !value[1]) {
callback(new Error('请选择归属周期'))
return
}
const monthRange = getMonthDateRange(this.formData.targetMonth)
if (!monthRange) {
callback(new Error('请先选择交付目标月份'))
return
}
if (value[0] !== monthRange.startDate) {
callback(new Error('归属周期开始日期必须为当月1号'))
return
}
if (value[1] < value[0] || value[1] > monthRange.endDate) {
callback(new Error('归属周期结束日期无效'))
return
}
callback()
}
}],
targetValue: [{ required: true, message: '请输入交付数', trigger: 'blur' }]
},
searchForm: {
id: ''
},
searchFormSearch: {},
// getListApi: findByMsgId,
tableData: [],
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: false,
tableColumns: [{
label: '操作项',
prop: 'operType',
formatter: (cellValue) => {
return this.operTypeOpt.find(item => item.confId === cellValue.operType)?.confValue + '交付数数据'
}
}, {
label: '操作时间',
prop: 'createdDate',
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss')
}
}, {
label: '操作人',
prop: 'createdBy'
}]
},
baseData: {
merchantList: []
},
carBrands: [],
operTypeOpt: deepClone(outputValue_operTypeOpt),
currentPage: 1,
pageSize: 20
// track_event_code: 'shopConfig_merchantDeliverTargeConfig_add',
// track_businessParam_key: 'searchForm'
}
},
name: "EditDialog",
components: {
PeriodDateRange: periodDateRange,
},
// mixins: [reportTrackFunMixin],
directives: {
"el-select-loadmore": {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
".el-select-dropdown .el-select-dropdown__wrap",
);
SELECTWRAP_DOM.addEventListener("scroll", function () {
const condition
= this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
}, 100);
},
},
},
props: {
visible: {
type: Boolean,
default: false
},
paramsObj: {
type: Object,
default: null
},
operationType: {
type: String,
default: ""
}
},
watch: {
},
computed: {
dialogShow: {
get() {
// this.setCode()
// this.onPageShow()
return this.visible
},
set(newVal) {
// this.onPageHide()
this.$emit('dialogClose', { flag: newVal })
}
}
},
props: {
visible: {
type: Boolean,
default: false,
},
paramsObj: {
type: Object,
default: null,
},
operationType: {
type: String,
default: "",
},
},
data() {
return {
config: {
appendToBody: true,
isShowFooter: true,
confirm_name: "确定",
cancel_name: "取消",
},
pickerOption: rangePickerOptions_deliveryQuantity,
userInfo: this.$store.state.d2admin.user.info,
formData: {
merchantId: "",
merchantName: "",
brand: [],
brandId: "",
brandName: "",
childId: "",
childName: "",
targetValue: "",
targetMonth: "",
periodRange: [],
periodDateStr: "",
},
oldVal: {
targetValue: "",
},
dialogConfig: {
title: "新增交付数",
// width: '700px'
width: "1080px",
},
formRules: {
merchantId: [{ required: true, message: "请选择4S门店", trigger: "change" }],
brand: [{ required: true, message: "请选择品牌", trigger: "change" }],
targetMonth: [{ required: true, message: "请选择交付目标月份", trigger: "change" }],
periodRange: [{
required: true,
trigger: "change",
validator: (rule, value, callback) => {
if (!value || value.length !== 2 || !value[0] || !value[1]) {
callback(new Error("请选择归属周期"));
return;
}
const monthRange = getMonthDateRange(this.formData.targetMonth);
if (!monthRange) {
callback(new Error("请先选择交付目标月份"));
return;
}
if (value[0] !== monthRange.startDate) {
callback(new Error("归属周期开始日期必须为当月1号"));
return;
}
if (value[1] < value[0] || value[1] > monthRange.endDate) {
callback(new Error("归属周期结束日期无效"));
return;
}
callback();
},
}],
targetValue: [{ required: true, message: "请输入交付数", trigger: "blur" }],
},
searchForm: {
id: "",
},
searchFormSearch: {},
// getListApi: findByMsgId,
tableData: [],
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: false,
tableColumns: [{
label: "操作项",
prop: "operType",
formatter: (cellValue) => {
return this.operTypeOpt.find(item => item.confId === cellValue.operType)?.confValue + "交付数数据";
},
}, {
label: "操作时间",
prop: "createdDate",
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss");
},
}, {
label: "操作人",
prop: "createdBy",
}],
},
baseData: {
merchantList: [],
},
carBrands: [],
operTypeOpt: deepClone(outputValue_operTypeOpt),
currentPage: 1,
pageSize: 20,
// track_event_code: 'shopConfig_merchantDeliverTargeConfig_add',
// track_businessParam_key: 'searchForm'
};
},
computed: {
dialogShow: {
get() {
// this.setCode()
// this.onPageShow()
return this.visible;
},
set(newVal) {
// this.onPageHide()
this.$emit("dialogClose", { flag: newVal });
},
},
},
watch: {
},
mounted() {
if (this.paramsObj) {
this.getInfo(this.paramsObj.id)
if (this.operationType == 'edit') {
this.dialogConfig.title = '修改交付数'
} else {
this.dialogConfig.title = '查看交付数详情'
this.config.isShowFooter = false
}
} else {
this.dialogConfig.title = '新增交付数'
this.getSelectingList()
}
},
mounted() {
if (this.paramsObj) {
this.getInfo(this.paramsObj.id);
if (this.operationType == "edit") {
this.dialogConfig.title = "修改交付数";
} else {
this.dialogConfig.title = "查看交付数详情";
this.config.isShowFooter = false;
}
} else {
this.dialogConfig.title = "新增交付数";
this.getSelectingList();
}
},
methods: {
// setCode() {
// if (this.paramsObj) {
// if (this.operationType == 'edit') {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_edit'
// } else {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_detail'
// }
// } else {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_add'
// }
// },
// 获取4S门店数据
remoteMethod(query) {
this.merchantName = query
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList() // 请求接口
},
getSelectingList(defaultSelect) {
getList({
merchantName: this.merchantName,
currentPage: this.currentPage,
pageSize: this.pageSize
}).then(res => {
this.allPages = res.pages
const resArr = [...res.list]
let arr = this.baseData.merchantList.concat(resArr)
if (defaultSelect?.length) arr = arr.concat(defaultSelect)
this.baseData.merchantList = arr
}).catch(() => {
})
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.merchantName) {
this.merchantName = ''
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList()
}
}
},
// 获取更多4S店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages
return
}
this.getSelectingList()
}, 10)
},
methods: {
// setCode() {
// if (this.paramsObj) {
// if (this.operationType == 'edit') {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_edit'
// } else {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_detail'
// }
// } else {
// this.track_event_code = 'shopConfig_merchantDeliverTargeConfig_add'
// }
// },
// 获取4S门店数据
remoteMethod(query) {
this.merchantName = query;
this.currentPage = 1;
this.baseData.merchantList = [];
this.getSelectingList(); // 请求接口
},
getSelectingList(defaultSelect) {
getList({
merchantName: this.merchantName,
currentPage: this.currentPage,
pageSize: this.pageSize,
}).then((res) => {
this.allPages = res.pages;
const resArr = [...res.list];
let arr = this.baseData.merchantList.concat(resArr);
if (defaultSelect?.length) {
arr = arr.concat(defaultSelect);
}
this.baseData.merchantList = arr;
}).catch(() => {
});
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.merchantName) {
this.merchantName = "";
this.currentPage = 1;
this.baseData.merchantList = [];
this.getSelectingList();
}
}
},
// 获取更多4S店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1;
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages;
return;
}
this.getSelectingList();
}, 10);
},
getInfo(id) {
getById_deliver({
id: id
}).then(res => {
this.formData = deepClone(res)
this.tableData = deepClone(res.logList)
// this.formData.brand = [this.formData.brandId, this.formData.childId]
// const obj = { merchantId: this.formData.merchantId, merchantName: this.formData.merchantName }
// this.getSelectingList(obj)
// this.getCarBrand(this.formData.merchantId)
this.formData.createdDateShow = this.formData.createdDate
? Util.dateFormate(this.formData.createdDate, 'YYYY-MM-DD HH:mm:ss')
: ""
this.fillPeriodRange()
}).catch(() => {
})
},
getInfo(id) {
getById_deliver({
id,
}).then((res) => {
this.formData = deepClone(res);
this.tableData = deepClone(res.logList);
// this.formData.brand = [this.formData.brandId, this.formData.childId]
// const obj = { merchantId: this.formData.merchantId, merchantName: this.formData.merchantName }
// this.getSelectingList(obj)
// this.getCarBrand(this.formData.merchantId)
this.formData.createdDateShow = this.formData.createdDate
? Util.dateFormate(this.formData.createdDate, "YYYY-MM-DD HH:mm:ss")
: "";
this.fillPeriodRange();
}).catch(() => {
});
},
fillPeriodRange() {
if (this.operationType === 'detail') return
let start = ''
let end = ''
if (this.formData.periodStartDate && this.formData.periodEndDate) {
start = Util.dateFormate(this.formData.periodStartDate, 'YYYY-MM-DD')
end = Util.dateFormate(this.formData.periodEndDate, 'YYYY-MM-DD')
} else if (this.formData.periodDateStr) {
const parsed = parsePeriodDateStr(this.formData.periodDateStr)
if (parsed) {
start = parsed[0]
end = parsed[1]
}
}
if (start && end) {
this.$set(this.formData, 'periodRange', [start, end])
}
},
fillPeriodRange() {
if (this.operationType === "detail") {
return;
}
let start = "";
let end = "";
if (this.formData.periodStartDate && this.formData.periodEndDate) {
start = Util.dateFormate(this.formData.periodStartDate, "YYYY-MM-DD");
end = Util.dateFormate(this.formData.periodEndDate, "YYYY-MM-DD");
} else if (this.formData.periodDateStr) {
const parsed = parsePeriodDateStr(this.formData.periodDateStr);
if (parsed) {
start = parsed[0];
end = parsed[1];
}
}
if (start && end) {
this.$set(this.formData, "periodRange", [start, end]);
}
},
handleTargetMonthChange() {
this.formData.periodRange = []
},
handleTargetMonthChange() {
this.formData.periodRange = [];
},
choose4S(merchantId) {
this.formData.brand = []
this.formData.brandId = ''
this.formData.brandName = ''
this.formData.childId = ''
this.formData.childName = ''
if (merchantId) {
this.getCarBrand(merchantId)
}
},
choose4S(merchantId) {
this.formData.brand = [];
this.formData.brandId = "";
this.formData.brandName = "";
this.formData.childId = "";
this.formData.childName = "";
if (merchantId) {
this.getCarBrand(merchantId);
}
},
getCarBrand(merchantId) {
getCarBrand({
merchantId: merchantId
}).then(res => {
this.carBrands = deepClone(res)
}).catch(() => {
})
},
getCarBrand(merchantId) {
getCarBrand({
merchantId,
}).then((res) => {
this.carBrands = deepClone(res);
}).catch(() => {
});
},
chooseBrand(value) {
const checkedNode = this.$refs.cascader.getCheckedNodes()[0]
const brandNode = checkedNode.pathNodes[0]
const childNode = checkedNode.pathNodes[1]
this.formData.brandId = brandNode.value
this.formData.brandName = brandNode.label
this.formData.childId = childNode.value
this.formData.childName = childNode.label
},
chooseBrand(value) {
const checkedNode = this.$refs.cascader.getCheckedNodes()[0];
const brandNode = checkedNode.pathNodes[0];
const childNode = checkedNode.pathNodes[1];
this.formData.brandId = brandNode.value;
this.formData.brandName = brandNode.label;
this.formData.childId = childNode.value;
this.formData.childName = childNode.label;
},
targetValue_handleInput(newVal) {
this.formData.targetValue = limitPrice(
newVal,
this.oldVal.targetValue,
11,
0,
0,
99999999999
)
this.oldVal.targetValue = this.formData.targetValue
},
targetValue_handleInput(newVal) {
this.formData.targetValue = limitPrice(
newVal,
this.oldVal.targetValue,
11,
0,
0,
99999999999,
);
this.oldVal.targetValue = this.formData.targetValue;
},
handleAddConfirm() {
if (this.operationType == 'detail') {
this.dialogShow = false
return
}
this.$refs.infoForm.validate(valid => {
if (valid) {
var params = deepClone(this.formData)
params.periodStartDate = params.periodRange[0]
params.periodEndDate = params.periodRange[1]
delete params.periodRange
if (params.id) {
updateDeliverTargeConfig(params).then(res => {
this.notice.okTips('操作成功')
this.dialogShow = true
})
} else {
params.merchantName = this.baseData.merchantList.find(item => item.merchantId == params.merchantId).merchantName
insertDeliverTargeConfig(params).then(res => {
this.notice.okTips('操作成功')
this.dialogShow = true
})
}
}
})
}
handleAddConfirm() {
if (this.operationType == "detail") {
this.dialogShow = false;
return;
}
this.$refs.infoForm.validate((valid) => {
if (valid) {
let params = deepClone(this.formData);
params.periodStartDate = params.periodRange[0];
params.periodEndDate = params.periodRange[1];
delete params.periodRange;
if (params.id) {
updateDeliverTargeConfig(params).then((res) => {
this.notice.okTips("操作成功");
this.dialogShow = true;
});
} else {
params.merchantName = this.baseData.merchantList.find(item => item.merchantId == params.merchantId).merchantName;
insertDeliverTargeConfig(params).then((res) => {
this.notice.okTips("操作成功");
this.dialogShow = true;
});
}
}
});
},
}
}
},
};
</script>
<style lang="scss" scoped>
.add-dialog {
margin: 20px 0;
.div-title {
width: 1040px;
height: 30px;
border-bottom: 1px solid #e5e5e5;
font-size: 16px;
font-weight: 600;
color: #333333;
margin: 10px 0 20px 0;
}
.sortInput {
width: 90%;
}
margin: 20px 0;
.div-title {
width: 1040px;
height: 30px;
border-bottom: 1px solid #e5e5e5;
font-size: 16px;
font-weight: 600;
color: #333333;
margin: 10px 0 20px 0;
}
.sortInput {
width: 90%;
}
}
</style>
<!-- 主机厂交付数 -->
<template>
<d2-container class="m-t-40">
<div class="header"
slot="header"
<div slot="header"
class="header"
style="padding-bottom: 20px;">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
label-width="120px"
:form-data="showFormData"
label-width="120px">
:search-form="searchForm">
<div slot="4sHtml">
<el-select v-model="searchForm.merchantIdList"
multiple
v-el-select-loadmore="interestsLoadmore"
placeholder="请选择4S店"
style="width: 100%;"
collapse-tags
filterable
multiple
remote
reserve-keyword
placeholder="请选择4S店"
@visible-change="visibleChange"
:remote-method="remoteMethod"
v-el-select-loadmore="interestsLoadmore"
style="width: 100%;"
filterable>
@visible-change="visibleChange">
<el-option v-for="subItem in baseData.merchantList"
:key="subItem.merchantId"
:label="`${subItem.merchantName}(${subItem.merchantId})`"
......@@ -30,17 +30,18 @@
</div>
<div slot="targetMonthHtml">
<el-date-picker v-model="searchForm.targetMonth"
type="month"
value-format="yyyy-MM"
format="yyyy-MM"
placeholder="选择月"
style="width: 100%;">
style="width: 100%;"
type="month"
value-format="yyyy-MM">
</el-date-picker>
</div>
<div slot="targetValueHtml">
<input-range start-placeholder="最小交付数"
end-placeholder="最大交付数"
:display-value="searchForm.targetValue"></input-range>
<InputRange end-placeholder="最大交付数"
start-placeholder="最小交付数"
:display-value="searchForm.targetValue">
</InputRange>
</div>
</d2-search>
<div class="up-btns">
......@@ -50,7 +51,9 @@
查询
</el-button>
<el-button size="small"
@click="handleReset"> 重置 </el-button>
@click="handleReset">
重置
</el-button>
</div>
</div>
<!-- </div> -->
......@@ -58,13 +61,14 @@
<d2-table-header>
<span>
<auth-button category="Button"
:show-btn-ids="['9061921','9061922','9061923']" /></span>
:show-btn-ids="['9061921', '9061922', '9061923']" />
</span>
</d2-table-header>
<d2-table ref="recordTable"
:search-form="searchFormSearch"
:table-params="tableParams"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
:search-form="searchFormSearch"
:table-params="tableParams">
<div slot="auth-button"
slot-scope="scope">
<!-- 详情 -->
......@@ -73,22 +77,22 @@
:show-btn-ids="['9061924']" />
</span>
<!-- 修改 -->
<span style="margin-right: 10px"
v-if="scope.scope.allowUpdate == true">
<span v-if="scope.scope.allowUpdate == true"
style="margin-right: 10px">
<auth-button :data="scope.scope"
:show-btn-ids="['9061925']" />
</span>
<!-- 删除 -->
<span style="margin-right: 10px"
v-if="scope.scope.allowUpdate == true">
<span v-if="scope.scope.allowUpdate == true"
style="margin-right: 10px">
<auth-button :data="scope.scope"
:show-btn-ids="['9061926']" />
</span>
</div>
</d2-table>
</div>
<d2-file-import-dialog :is-visible="fileVisible"
title="交付数导入"
<d2-file-import-dialog title="交付数导入"
:is-visible="fileVisible"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="exportTemplate">
......@@ -96,462 +100,465 @@
<el-form-item label="交付目标月份:"
required>
<el-date-picker v-model="importForm.targetMonth"
type="month"
value-format="yyyy-MM"
format="yyyy-MM"
placeholder="选择月"
:picker-options="importMonthPickerOption"
style="width: 100%;"
type="month"
value-format="yyyy-MM"
:picker-options="importMonthPickerOption"
@change="handleImportTargetMonthChange" />
</el-form-item>
<el-form-item label="归属周期:"
required>
<period-date-range v-model="importForm.periodRange"
:target-month="importForm.targetMonth" />
<PeriodDateRange v-model="importForm.periodRange"
:target-month="importForm.targetMonth" />
</el-form-item>
</template>
</d2-file-import-dialog>
<!-- 新增&修改&详情 -->
<edit-dialog :visible.sync="editVisible"
v-if="editVisible"
:params-obj="recordInfo"
:operation-type="operationType"
@dialogClose="closeEditDialog" />
<EditDialog v-if="editVisible"
:operation-type="operationType"
:params-obj="recordInfo"
:visible.sync="editVisible"
@dialogClose="closeEditDialog" />
</d2-container>
</template>
<script>
import { mapActions, mapState } from "vuex"
import { Util, deepClone } from "@/common/util"
import inputRange from './components/inputRange'
import editDialog from "./components/editDialog"
import periodDateRange from './components/periodDateRange'
import { listWithPage_deliver, deliverTargeConfigImport, deleteById_deliver, distinctAllBrand } from '@api/shopConfig'
import { getList } from "@api/merchant"
import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
import { rangePickerOptions_deliveryQuantity_import } from '@/common/format'
import { getList } from "@api/merchant";
import { deleteById_deliver, deliverTargeConfigImport, distinctAllBrand, listWithPage_deliver } from "@api/shopConfig";
import { mapActions, mapState } from "vuex";
import { rangePickerOptions_deliveryQuantity_import } from "@/common/format";
import { deepClone, Util } from "@/common/util";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import editDialog from "./components/editDialog";
import inputRange from "./components/inputRange";
import periodDateRange from "./components/periodDateRange";
export default {
name: "DeliveryQuantity",
mixins: [reportTrackFunMixin], // 导入混入
directives: {
'el-select-loadmore': {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
'.el-select-dropdown .el-select-dropdown__wrap'
)
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition =
this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) {
binding.value()
}
})
}, 100)
}
}
},
data() {
return {
searchForm: {
merchantIdList: [],
brandChildIdList: [],
targetMonth: "",
targetValue: [],
createTime: ""
},
searchFormSearch: {},
showFormData: [
{
label: "4S门店",
name: "merchantIdList",
addHtml: "4sHtml"
},
{
label: "品牌",
name: "brandId",
type: "select",
isClear: true,
optionList: [],
optionId: "childId",
optionLabel: "childName",
optionsName: "brandList"
},
{
label: '交付目标月份',
name: 'targetMonth',
addHtml: "targetMonthHtml"
},
{
label: '交付数',
name: 'targetValue',
addHtml: "targetValueHtml"
},
{
label: '导入时间',
name: 'createTime',
type: 'datePicker',
isClear: true,
pickerOptions: 'rangePickerOptions'
}
],
getListApi: listWithPage_deliver,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableOption: { width: "150px" },
tableColumns: [
{
label: "4S门店",
prop: "merchantId",
formatter: (cellValue) => {
return cellValue.merchantName + "(" + cellValue.merchantId + ")"
}
},
{
label: "品牌",
prop: "childName",
width: "300"
},
{
label: "交付目标月份",
prop: "targetMonth",
width: "150"
},
{
label: "归属周期",
prop: "periodDateStr",
width: "200",
formatter: (cellValue) => {
return cellValue.periodDateStr || "-"
}
},
{
label: "交付数",
prop: "targetValue",
width: "200",
formatter: (cellValue) => {
return (cellValue.targetValue || cellValue.targetValue == 0) ? cellValue.targetValue : "-"
}
},
{
label: "导入时间",
prop: "createdDate",
width: "180",
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss")
}
}
]
},
baseData: {
merchantList: [],
brandList: []
},
recordInfo: null,
operationType: "add",
currentPage: 1,
pageSize: 20,
fileVisible: false,
editVisible: false,
importMonthPickerOption: rangePickerOptions_deliveryQuantity_import,
importForm: {
targetMonth: '',
periodRange: []
},
track_event_code: 'shopConfig_deliver_list',
track_businessParam_key: 'searchForm'
}
},
name: "DeliveryQuantity", // 导入混入
directives: {
"el-select-loadmore": {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
".el-select-dropdown .el-select-dropdown__wrap",
);
SELECTWRAP_DOM.addEventListener("scroll", function () {
const condition
= this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
}, 100);
},
},
},
components: {
inputRange,
editDialog,
periodDateRange
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList
})
},
mounted() {
this.onPageShow()
this.getBaseData()
},
components: {
InputRange: inputRange,
EditDialog: editDialog,
PeriodDateRange: periodDateRange,
},
mixins: [reportTrackFunMixin],
data() {
return {
searchForm: {
merchantIdList: [],
brandChildIdList: [],
targetMonth: "",
targetValue: [],
createTime: "",
},
searchFormSearch: {},
showFormData: [
{
label: "4S门店",
name: "merchantIdList",
addHtml: "4sHtml",
},
{
label: "品牌",
name: "brandId",
type: "select",
isClear: true,
optionList: [],
optionId: "childId",
optionLabel: "childName",
optionsName: "brandList",
},
{
label: "交付目标月份",
name: "targetMonth",
addHtml: "targetMonthHtml",
},
{
label: "交付数",
name: "targetValue",
addHtml: "targetValueHtml",
},
{
label: "导入时间",
name: "createTime",
type: "datePicker",
isClear: true,
pickerOptions: "rangePickerOptions",
},
],
getListApi: listWithPage_deliver,
// 表格参数
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: { width: "150px" },
tableColumns: [
{
label: "4S门店",
prop: "merchantId",
formatter: (cellValue) => {
return cellValue.merchantName + "(" + cellValue.merchantId + ")";
},
},
{
label: "品牌",
prop: "childName",
width: "300",
},
{
label: "交付目标月份",
prop: "targetMonth",
width: "150",
},
{
label: "归属周期",
prop: "periodDateStr",
width: "200",
formatter: (cellValue) => {
return cellValue.periodDateStr || "-";
},
},
{
label: "交付数",
prop: "targetValue",
width: "200",
formatter: (cellValue) => {
return (cellValue.targetValue || cellValue.targetValue == 0) ? cellValue.targetValue : "-";
},
},
{
label: "导入时间",
prop: "createdDate",
width: "180",
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss");
},
},
],
},
baseData: {
merchantList: [],
brandList: [],
},
recordInfo: null,
operationType: "add",
currentPage: 1,
pageSize: 20,
fileVisible: false,
editVisible: false,
importMonthPickerOption: rangePickerOptions_deliveryQuantity_import,
importForm: {
targetMonth: "",
periodRange: [],
},
track_event_code: "shopConfig_deliver_list",
track_businessParam_key: "searchForm",
};
},
computed: {
...mapState({
dowloadList: state => state.d2admin.user.dowloadList,
updateList: state => state.d2admin.user.updateList,
}),
},
mounted() {
this.onPageShow();
this.getBaseData();
},
methods: {
...mapActions({
get: "d2admin/base/get",
close: "d2admin/page/close"
}),
...mapActions("d2admin/user", ["actionSetDownloadList"]),
methods: {
...mapActions({
get: "d2admin/base/get",
close: "d2admin/page/close",
}),
...mapActions("d2admin/user", ["actionSetDownloadList"]),
async getBaseData() {
this.getOptionsList()
this.getSelectingList()
this.getBrands()
},
async getBaseData() {
this.getOptionsList();
this.getSelectingList();
this.getBrands();
},
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchFormSearch.createTime) {
this.searchFormSearch.startCreatedDate = Util.dateFormate(this.searchFormSearch.createTime[0], 'YYYY-MM-DD HH:mm:ss')
this.searchFormSearch.endCreatedDate = Util.dateFormate(this.searchFormSearch.createTime[1], 'YYYY-MM-DD') + ' 23:59:59'
} else {
delete this.searchFormSearch.startCreatedDate
delete this.searchFormSearch.endCreatedDate
}
if (this.searchFormSearch.targetValue && this.searchFormSearch.targetValue.length > 0) {
this.searchFormSearch.minTargetValue = this.searchFormSearch.targetValue[0]
this.searchFormSearch.maxTargetValue = this.searchFormSearch.targetValue[1]
} else {
delete this.searchFormSearch.minTargetValue
delete this.searchFormSearch.maxTargetValue
}
if (this.searchFormSearch.brandId) {
this.searchFormSearch.brandChildIdList.push(this.searchFormSearch.brandId)
delete this.searchFormSearch.brandId
} else {
this.searchFormSearch.brandChildIdList = []
}
resolve()
})
},
// 获取商品数据
remoteMethod(query) {
this.merchantName = query
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList() // 请求接口
},
getSelectingList(defaultSelect) {
getList({
merchantName: this.merchantName,
currentPage: this.currentPage,
pageSize: this.pageSize
}).then(res => {
this.allPages = res.pages
const resArr = [...res.list]
const arr = this.baseData.merchantList.concat(resArr)
this.baseData.merchantList = arr
this.getOptionsList()
}).catch(() => {
})
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.merchantName) {
this.merchantName = ''
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList()
}
}
},
// 获取更多4S店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages
return
}
this.getSelectingList()
}, 10)
},
getBrands() {
distinctAllBrand({}).then(res => {
this.baseData.brandList = res
this.getOptionsList()
}).catch(() => {
})
},
handleReset() {
this.searchForm = {
merchantIdList: [],
brandChildIdList: [],
targetMonth: "",
targetValue: [],
createTime: ""
}
this.$refs.recordTable.refreshTable()
},
getOptionsList() {
this.showFormData.forEach((item, index) => {
if (item.type === 'select') {
if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
const temp = {}
temp[this.showFormData[index].optionId] = ''
temp[this.showFormData[index].optionLabel] = '全部'
this.baseData[item.optionsName].unshift(temp)
}
this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
}
})
},
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm);
if (this.searchFormSearch.createTime) {
this.searchFormSearch.startCreatedDate = Util.dateFormate(this.searchFormSearch.createTime[0], "YYYY-MM-DD HH:mm:ss");
this.searchFormSearch.endCreatedDate = Util.dateFormate(this.searchFormSearch.createTime[1], "YYYY-MM-DD") + " 23:59:59";
} else {
delete this.searchFormSearch.startCreatedDate;
delete this.searchFormSearch.endCreatedDate;
}
if (this.searchFormSearch.targetValue && this.searchFormSearch.targetValue.length > 0) {
this.searchFormSearch.minTargetValue = this.searchFormSearch.targetValue[0];
this.searchFormSearch.maxTargetValue = this.searchFormSearch.targetValue[1];
} else {
delete this.searchFormSearch.minTargetValue;
delete this.searchFormSearch.maxTargetValue;
}
if (this.searchFormSearch.brandId) {
this.searchFormSearch.brandChildIdList.push(this.searchFormSearch.brandId);
delete this.searchFormSearch.brandId;
} else {
this.searchFormSearch.brandChildIdList = [];
}
resolve();
});
},
// 获取商品数据
remoteMethod(query) {
this.merchantName = query;
this.currentPage = 1;
this.baseData.merchantList = [];
this.getSelectingList(); // 请求接口
},
getSelectingList(defaultSelect) {
getList({
merchantName: this.merchantName,
currentPage: this.currentPage,
pageSize: this.pageSize,
}).then((res) => {
this.allPages = res.pages;
const resArr = [...res.list];
const arr = this.baseData.merchantList.concat(resArr);
this.baseData.merchantList = arr;
this.getOptionsList();
}).catch(() => {
});
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.merchantName) {
this.merchantName = "";
this.currentPage = 1;
this.baseData.merchantList = [];
this.getSelectingList();
}
}
},
// 获取更多4S店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1;
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages;
return;
}
this.getSelectingList();
}, 10);
},
getBrands() {
distinctAllBrand({}).then((res) => {
this.baseData.brandList = res;
this.getOptionsList();
}).catch(() => {
});
},
handleReset() {
this.searchForm = {
merchantIdList: [],
brandChildIdList: [],
targetMonth: "",
targetValue: [],
createTime: "",
};
this.$refs.recordTable.refreshTable();
},
getOptionsList() {
this.showFormData.forEach((item, index) => {
if (item.type === "select") {
if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== "全部") {
const temp = {};
temp[this.showFormData[index].optionId] = "";
temp[this.showFormData[index].optionLabel] = "全部";
this.baseData[item.optionsName].unshift(temp);
}
this.$set(this.showFormData[index], "optionList", this.baseData[item.optionsName]);
}
});
},
handleAdd() {
this.recordInfo = null
this.operationType = 'add'
this.editVisible = true
},
handleAdd() {
this.recordInfo = null;
this.operationType = "add";
this.editVisible = true;
},
handleDetail(row) {
this.recordInfo = row
this.operationType = 'detail'
this.editVisible = true
},
handleDetail(row) {
this.recordInfo = row;
this.operationType = "detail";
this.editVisible = true;
},
handleEdit(row) {
this.recordInfo = row
this.operationType = 'edit'
this.editVisible = true
},
handleEdit(row) {
this.recordInfo = row;
this.operationType = "edit";
this.editVisible = true;
},
closeEditDialog(obj) {
this.editVisible = !this.editVisible
if (obj.flag) {
this.$refs.recordTable.refreshTable(false, true)
}
},
closeEditDialog(obj) {
this.editVisible = !this.editVisible;
if (obj.flag) {
this.$refs.recordTable.refreshTable(false, true);
}
},
handleExport() {
var params = this.searchFormSearch
if (params.merchantIdList.length > 0) {
params.merchantIdList.forEach((item, index) => {
const merchantId = `merchantIdList[${index}]`
params[merchantId] = item
})
delete params.merchantIdList
}
if (params.brandChildIdList.length > 0) {
params.brandChildIdList.forEach((item, index) => {
const brandChildId = `brandChildIdList[${index}]`
params[brandChildId] = item
})
delete params.brandChildIdList
}
// 去除为null的值
for (const key in params) {
if (params[key] === null || params[key] === '' || params[key].length == 0) {
delete params[key]
}
}
params.method = 'dj.api.smartcarlife.merchantDeliverTargeConfig.export.async'
const list = [
...this.dowloadList,
{
name: '门店主机厂交付数',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
handleExport() {
let params = this.searchFormSearch;
if (params.merchantIdList.length > 0) {
params.merchantIdList.forEach((item, index) => {
const merchantId = `merchantIdList[${index}]`;
params[merchantId] = item;
});
delete params.merchantIdList;
}
if (params.brandChildIdList.length > 0) {
params.brandChildIdList.forEach((item, index) => {
const brandChildId = `brandChildIdList[${index}]`;
params[brandChildId] = item;
});
delete params.brandChildIdList;
}
// 去除为null的值
for (const key in params) {
if (params[key] === null || params[key] === "" || params[key].length == 0) {
delete params[key];
}
}
params.method = "dj.api.smartcarlife.merchantDeliverTargeConfig.export.async";
const list = [
...this.dowloadList,
{
name: "门店主机厂交付数",
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime(),
},
];
this.actionSetDownloadList({ list, type: "dowloadList" });
},
// 门店主机厂交付数导入模版下载
exportTemplate() {
var params = {}
params.method = 'dj.api.smartcarlife.merchantDeliverTargeConfig.template.export'
const list = [
...this.dowloadList,
{
name: '门店主机厂交付数导入模版',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
// 门店主机厂交付数导入模版下载
exportTemplate() {
let params = {};
params.method = "dj.api.smartcarlife.merchantDeliverTargeConfig.template.export";
const list = [
...this.dowloadList,
{
name: "门店主机厂交付数导入模版",
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime(),
},
];
this.actionSetDownloadList({ list, type: "dowloadList" });
},
handleImport() {
if (this.fileVisible) {
this.resetImportForm()
}
this.fileVisible = !this.fileVisible
},
handleImport() {
if (this.fileVisible) {
this.resetImportForm();
}
this.fileVisible = !this.fileVisible;
},
resetImportForm() {
this.importForm = {
targetMonth: '',
periodRange: []
}
},
resetImportForm() {
this.importForm = {
targetMonth: "",
periodRange: [],
};
},
handleImportTargetMonthChange() {
this.importForm.periodRange = []
},
handleImportTargetMonthChange() {
this.importForm.periodRange = [];
},
validateImportForm() {
if (!this.importForm.targetMonth) {
this.notice.warningTips('请选择交付目标月份')
return false
}
const { periodRange } = this.importForm
if (!periodRange || periodRange.length !== 2 || !periodRange[0] || !periodRange[1]) {
this.notice.warningTips('请选择归属周期')
return false
}
return true
},
validateImportForm() {
if (!this.importForm.targetMonth) {
this.notice.warningTips("请选择交付目标月份");
return false;
}
const { periodRange } = this.importForm;
if (!periodRange || periodRange.length !== 2 || !periodRange[0] || !periodRange[1]) {
this.notice.warningTips("请选择归属周期");
return false;
}
return true;
},
handleConfirmImport({ fileName, fileData }) {
if (!this.validateImportForm()) return
var params = {
file: fileData,
targetMonth: this.importForm.targetMonth,
periodStartDate: this.importForm.periodRange[0],
periodEndDate: this.importForm.periodRange[1]
}
deliverTargeConfigImport(params).then(res => {
if (res) {
const list = [...this.updateList, {
name: fileName,
ifSuccess: false,
uuid: res,
type: 'upload'
}]
handleConfirmImport({ fileName, fileData }) {
if (!this.validateImportForm()) {
return;
}
let params = {
file: fileData,
targetMonth: this.importForm.targetMonth,
periodStartDate: this.importForm.periodRange[0],
periodEndDate: this.importForm.periodRange[1],
};
deliverTargeConfigImport(params).then((res) => {
if (res) {
const list = [...this.updateList, {
name: fileName,
ifSuccess: false,
uuid: res,
type: "upload",
}];
this.actionSetDownloadList({ list, type: 'updateList' })
this.notice.okTips('上传成功')
this.$refs.recordTable.refreshTable(false, true)
this.resetImportForm()
this.handleImport()
}
})
},
this.actionSetDownloadList({ list, type: "updateList" });
this.notice.okTips("上传成功");
this.$refs.recordTable.refreshTable(false, true);
this.resetImportForm();
this.handleImport();
}
});
},
// 删除
handleDelete(row) {
this.$confirm('请确认是否要执行当前操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
closeOnClickModal: false
}).then(() => {
deleteById_deliver({ id: row.id }).then(res => {
this.notice.okTips()
this.$refs.recordTable.refreshTable()
})
}).catch(err => {
console.log(err)
})
}
},
beforeDestroy() {
this.onPageHide()
}
}
// 删除
handleDelete(row) {
this.$confirm("请确认是否要执行当前操作?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false,
}).then(() => {
deleteById_deliver({ id: row.id }).then((res) => {
this.notice.okTips();
this.$refs.recordTable.refreshTable();
});
}).catch((err) => {
console.log(err);
});
},
},
beforeDestroy() {
this.onPageHide();
},
};
</script>
<style lang="scss" scoped>
.m-t-40 {
margin-top: 40px;
margin-top: 40px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!