You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

536 lines
19 KiB

<template>
<basic-container>
<div class="avue-crud">
<el-row :hidden="!search" style="padding:6px 18px">
<!-- 查询模块 -->
<el-form :inline="true" :model="query">
<el-form-item label="地址:">
<!-- <el-input v-model="query.province" placeholder="请输入省"></el-input>-->
<el-cascader :options="optioner" v-model="query.province">
<template #default="{ node, data }">
<span>{{ data.label }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
<!-- <el-form-item label="市:">-->
<!-- <el-input v-model="query.city" placeholder="请输入市"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="区/县:">-->
<!-- <el-input v-model="query.district" placeholder="请输入区/县"></el-input>-->
<!-- </el-form-item>-->
<el-form-item label="品牌:">
<el-input v-model="query.brand" placeholder="请输入品牌"></el-input>
</el-form-item>
<el-form-item label="费用类型:">
<!-- <el-input v-model="query.freightMark" placeholder="请输入费用标识"></el-input>-->
<el-select v-model="query.freightMark" class="m-2" placeholder="请选择客户类型" >
<el-option
v-for="item in clientType"
:key="item.dictKey"
:label="item.dictValue"
:value="item.dictKey"
/>
</el-select>
</el-form-item>
<el-form-item label="末端仓:">
<el-input v-model="query.goalGranary" placeholder="请输入末端仓"></el-input>
</el-form-item>
<!-- <el-form-item label="状态:">-->
<!-- <el-input v-model="query.condition" placeholder="请输入状态"></el-input>-->
<!-- </el-form-item>-->
<!-- 查询按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="searchChange"> </el-button>
<el-button icon="el-icon-delete" @click="searchReset()"> </el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="avue-crud__header">
<!-- 头部左侧按钮模块 -->
<div class="avue-crud__left">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd"> </el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain> </el-button>
</div>
<!-- 头部右侧按钮模块 -->
<div class="avue-crud__right">
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
<el-button icon="el-icon-search" @click="searchHide" circle></el-button>
</div>
</div>
</el-row>
<el-row>
<!-- 列表模块 -->
<el-table ref="table" v-loading="loading"
@selection-change="selectionChange"
:data="data"
:height="height"
style="width: 100%"
:border="option.border">
<el-table-column type="selection" v-if="option.selection" width="55" align="center"></el-table-column>
<el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
<el-table-column v-if="option.index" label="序号" type="index" width="60" align="center">
</el-table-column>
<template v-for="(item,index) in option.column">
<!-- table字段 -->
<el-table-column v-if="item.hide!==true"
:prop="item.prop"
:label="item.label"
:key="index" align="center">
</el-table-column>
</template>
<!-- 操作栏模块 -->
<el-table-column prop="menu" label="操作" :width="220" align="center">
<template #="{row}">
<el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>
<el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" text icon="el-icon-delete" @click="rowDel(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
<el-row>
<div class="avue-crud__pagination" style="width:100%">
<!-- 分页模块 -->
<el-pagination align="right"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="page.currentPage"
:page-sizes="[10, 20, 30, 40, 50, 100]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total">
</el-pagination>
</div>
</el-row>
<!-- 表单模块 -->
<el-dialog :title="title"
v-model="box"
width="35%"
:before-close="beforeClose"
append-to-body>
<el-form :disabled="view" ref="form" :model="form" label-width="120px">
<!-- 表单字段 -->
<el-form-item label="地址" prop="province">
<!-- <el-input v-model="form.province" placeholder="请输入省"/>-->
<el-cascader :options="optioner" v-model="form.province" style="width: 100%">
<template #default="{ node, data }">
<span>{{ data.label }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
<!-- <el-form-item label="市" prop="city">-->
<!-- <el-input v-model="form.city" placeholder="请输入市"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="区/县" prop="district">-->
<!-- <el-input v-model="form.district" placeholder="请输入区/县"/>-->
<!-- </el-form-item>-->
<el-form-item label="品牌" prop="brand">
<!-- <el-input v-model="form.brand" placeholder="请输入品牌"/>-->
<el-select style="width: 100%"
v-model="form.brand"
filterable
remote
reserve-keyword
placeholder="请选择品牌"
:remote-method="remoteMethod"
:loading="loading"
>
<el-option
v-for="item in optionsr"
:key="item.id"
:label="item.brandName"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="费用类型" prop="freightMark">
<!-- <el-input v-model="form.freightMark" placeholder="请输入费用标识;1 运费 2 送货费用 3提货费用 4仓库管理费用 5 仓储费用 6装卸费用 7 其他费用 8仓储时间端费用"/>-->
<el-select v-model="form.freightMark" class="m-2" placeholder="请输入费用标识" style="width: 100%">
<el-option
v-for="item in clientType"
:key="item.dictKey"
:label="item.dictValue"
:value="item.dictKey"
/>
</el-select>
</el-form-item>
<el-form-item label="费用" prop="cost">
<el-input v-model="form.cost" placeholder="请输入费用"/>
</el-form-item>
<el-form-item label="仓储时间端状态" prop="warehousingTimeStatus">
<!-- <el-input v-model="form.warehousingTimeStatus" placeholder="请输入仓储时间端状态;1 0-30天 2 0-60天 3 60天以上"/>-->
<el-select v-model="form.warehousingTimeStatus" class="m-2" placeholder="请输入仓储时间端状态" >
<el-option
v-for="item in wareType"
:key="item.dictKey"
:label="item.dictValue"
:value="item.dictKey"
/>
</el-select>
</el-form-item>
<el-form-item label="仓储时间端费用" prop="warehousingTimeCharge">
<el-input type="number" v-model="form.warehousingTimeCharge" placeholder="请输入仓储时间端费用"/>
</el-form-item>
<el-form-item label="末端仓" prop="goalGranary">
<!-- <el-input v-model="form.goalGranary" placeholder="请输入末端仓"/>-->
<el-select style="width: 100%"
v-model="form.goalGranary"
filterable
remote
reserve-keyword
placeholder="请输入末端仓"
:remote-method="remoteMethodBin"
:loading="loading"
>
<el-option
v-for="item in optionser"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- <el-form-item label="标识" prop="identification">-->
<!-- <el-input v-model="form.identification" placeholder="请输入标识"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="状态" prop="condition">-->
<!-- <el-input v-model="form.condition" placeholder="请输入状态"/>-->
<!-- </el-form-item>-->
</el-form>
<!-- 表单按钮 -->
<template #footer>
<span v-if="!view" class="dialog-footer">
<el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit"> </el-button>
<el-button icon="el-icon-circle-close" @click="box = false"> </el-button>
</span>
</template>
</el-dialog>
</div>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from "@/api/basicdata/basicZonePrice";
import { getListBinName} from "@/api/basicdata/basicdataWarehouse";
import {getListName} from "@/api/basicdata/basicBrand";
import option from "@/option/basicdata/basicZonePrice";
import { mapGetters } from "vuex";
import { getLazyTreeAll } from '@/api/base/region';
import { getDictionaryBiz } from '@/api/system/dict';
export default {
data () {
return {
height: 0,
// 弹框标题
title: '',
// 是否展示弹框
box: false,
// 是否显示查询
search: true,
// 加载中
loading: true,
// 是否为查看模式
view: false,
// 查询信息
query: {},
clientType:[], //字典
wareType:[], //字典
// 分页信息
page: {
currentPage: 1,
pageSize: 10,
total: 40
},
// 表单数据
form: {},
// 选择行
selectionList: [],
// 表单配置
option: option,
// 表单列表
data: [],
optioner:[],
optionsr:[],
optionser:[],
}
},
created() {
getLazyTreeAll().then( res => {
if(res.data.success){
console.log("this.optioner>>>>>>>>>>>>>>");
this.optioner = res.data.data;
this.onLoad(this.page);
}
})
},
mounted () {
this.init();
},
computed: {
...mapGetters(["permission"]),
ids () {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(",");
}
},
methods: {
remoteMethod(query){
if (query) {
this.loading = true
setTimeout(async () => {
this.loading = false;
let list = await getListName(this.page.currentPage, this.page.pageSize, { brandName: query });
this.optionsr = list.data.data.records.filter((item) => {
return item.brandName.toLowerCase().includes(query.toLowerCase())
})
}, 200)
} else {
this.optionsr = [];
}
},
remoteMethodBin(query){
if (query) {
this.loading = true
setTimeout(async () => {
this.loading = false;
let list = await getListBinName(this.page.currentPage, this.page.pageSize, { name: query });
this.optionser = list.data.data.records.filter((item) => {
return item.name.toLowerCase().includes(query.toLowerCase())
})
}, 200)
} else {
this.optionser = [];
}
},
init () {
this.height = this.setPx(document.body.clientHeight - 340);
//字典
getDictionaryBiz('jg_freight_mark').then(res => {
// console.log("字典》》》",res);
this.clientType = res.data.data;
});
//字典
getDictionaryBiz('warehousing_time_status').then(res => {
// console.log("字典》》》",res);
this.wareType = res.data.data;
});
},
searchHide () {
this.search = !this.search;
},
searchChange () {
this.onLoad(this.page);
},
searchReset () {
this.query = {};
this.page.currentPage = 1;
this.onLoad(this.page);
},
handleSubmit () {
if (!this.form.id) {
this.form.city = this.form.province[1];
this.form.district = this.form.province[2];
this.form.province = this.form.province[0];
console.log("提交的数据》》》",this.form);
add(this.form).then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
});
} else {
this.form.city = this.form.province[1];
this.form.district = this.form.province[2];
this.form.province = this.form.province[0];
if(JSON.stringify(this.form.goalGranary).length < 15){
this.form.goalGranary = null;
}
if(JSON.stringify(this.form.brand).length < 15){
this.form.brand = null;
}
update(this.form).then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
})
}
},
handleAdd () {
this.title = '新增'
this.form = {}
this.box = true
},
handleEdit (row) {
this.title = '编辑'
this.box = true
getDetail(row.id).then(res => {
this.form = res.data.data;
let a= [];
if(!!this.form.province){
a.push(res.data.data.province);
a.push(res.data.data.city);
a.push(res.data.data.district);
}
this.form.province = a;
this.form.goalGranary = row.name;
this.form.brand = row.brandName;
});
},
handleView (row) {
console.log("row>>>>>>>>",row);
this.title = '查看'
this.view = true;
this.box = true;
getDetail(row.id).then(res => {
this.form = res.data.data;
let a= [];
if(!!this.form.province){
a.push(res.data.data.province);
a.push(res.data.data.city);
a.push(res.data.data.district);
}
this.form.province = a;
this.form.goalGranary = row.name;
this.form.brand = row.brandName;
});
},
handleDelete () {
if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据");
return;
}
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.selectionClear();
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
});
},
rowDel (row) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
});
},
beforeClose (done) {
done()
this.form = {};
this.view = false;
},
selectionChange (list) {
this.selectionList = list;
},
selectionClear () {
this.selectionList = [];
this.$refs.table.clearSelection();
},
currentChange (currentPage) {
this.page.currentPage = currentPage;
this.onLoad(this.page);
},
sizeChange (pageSize) {
this.page.pageSize = pageSize;
this.onLoad(this.page);
},
onLoad (page, params = {}) {
this.loading = true;
if(!!this.query.province){
this.query.city = this.query.province[1];
this.query.district = this.query.province[2];
this.query.province = this.query.province[0];
}
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.clientType.forEach(it =>{
data.records.forEach(i =>{
if(parseInt( it.dictKey ) == parseInt(i.freightMark)){
i.freightMark = it.dictValue
}
if(i.freightMark == '-1'){
i.freightMark = '无'
}
})
})
this.wareType.forEach(it =>{
data.records.forEach(i =>{
if(parseInt( it.dictKey ) == parseInt(i.warehousingTimeStatus)){
i.warehousingTimeStatus = it.dictValue
}
if(i.warehousingTimeStatus == '-1'){
i.warehousingTimeStatus = '无'
}
})
})
this.page.total = data.total;
this.data = data.records;
let dz ="";
console.log("this.optioner>>>>>>>>data.records>>>>>>");
data.records.forEach(it =>{
let arrsheng = this.optioner.filter((i) => {
return it.province == i.value;
});
// console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
let arrshi = arrsheng[0].children.filter((i) => {
return it.city == i.value;
});
// console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
let arrqu = arrshi[0].children.filter((i) => {
return it.district == i.value;
});
// console.log("========",JSON.parse(JSON.stringify(arrsheng)) );
dz = arrsheng[0].label+"/"+arrshi[0].label+"/"+arrqu[0].label;
it.province = dz;
})
this.loading = false;
this.selectionClear();
});
}
}
};
</script>