123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- <template>
- <div>
- <div style="display:flex">
- <el-select
- v-if="gysType == 'CK'"
- size="small"
- v-model="value"
- placeholder="请选择"
- @input="$emit('balabala', value)"
- :disabled="disabled"
- filterable
- clearable
- style="width:100%"
- :multiple="multiple ? multiple : false"
- :collapse-tags="collapseTags ? collapseTags : false"
- @change="corpChange"
- >
- <el-option
- v-for="item in corpList"
- :key="item.id"
- :label="item.code"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-select
- v-else
- size="small"
- v-model="value"
- placeholder="请选择"
- @input="$emit('balabala', value)"
- :disabled="disabled"
- filterable
- clearable
- style="width:100%"
- @clear="clear"
- :multiple="multiple ? multiple : false"
- :collapse-tags="collapseTags ? collapseTags : false"
- @change="corpChange"
- >
- <el-option
- v-for="item in corpList"
- :key="item.id"
- :label="label?item[label]:item.cname"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-button
- icon="el-icon-search"
- size="mini"
- v-if="label != 'shortName'"
- :disabled="disabled"
- @click="openDialog()"
- ></el-button>
- </div>
- <el-dialog
- :title="title"
- :visible.sync="corpVisible"
- width="80%"
- top="5vh"
- append-to-body
- @closed="closed"
- class="el-dialogDeep"
- :close-on-click-modal="false"
- v-dialog-drag
- >
- <span>
- <el-row>
- <el-col :span="4">
- <el-scrollbar>
- <basic-container>
- <avue-tree
- :option="treeOption"
- :data="treeData"
- @node-click="nodeClick"
- :style="treeStyle"
- />
- </basic-container>
- </el-scrollbar>
- </el-col>
- <el-col :span="20">
- <avue-crud
- :option="tableOption"
- :data="data"
- ref="crud"
- v-model="form"
- :page.sync="page"
- :search.sync="search"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @on-load="onLoad"
- @tree-load="treeLoad"
- @saveColumn="saveColumn"
- @resetColumn="resetColumn"
- @refresh-change="refreshChange"
- :table-loading="loading"
- >
- </avue-crud>
- </el-col>
- </el-row>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="corpVisible = false">取 消</el-button>
- <el-button
- type="primary"
- @click="importCorp"
- :disabled="!multiple && selectionList.length != 1"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import option from "./configuration/mainList.json";
- import {
- customerList,
- allCropList,
- getDeptLazyTree
- } from "@/api/basicData/customerInformation";
- import { getCustomerCode, getCustomerName } from "@/enums/management-type";
- export default {
- data() {
- return {
- corpList: [],
- loading: false,
- data: [],
- tableOption: {},
- form: {},
- search: {},
- treeDeptId: "",
- treeDeptName: "",
- page: {
- currentPage: 1,
- pageSize: 10,
- total: 0,
- pageSizes: [10, 50, 100, 200, 300, 400, 500, 1000]
- },
- treeOption: {
- nodeKey: "id",
- lazy: true,
- addBtn: false,
- menu: false,
- size: "small",
- props: {
- labelText: "标题",
- label: "title",
- value: "value",
- children: "children"
- }
- },
- corpVisible: false,
- selectionList: [],
- title: null,
- treeStyle: "height:" + (window.innerHeight - 315) + "px"
- };
- },
- props: {
- value: String,
- disabled: Boolean,
- cropIndex: Number,
- corpType: String,
- multiple: Boolean,
- collapseTags: Boolean,
- gysType: String,
- treeType: String,
- label: String,
- belongtocompany: Number
- },
- model: {
- prop: "value",
- event: "balabala"
- },
- async created() {
- this.tableOption = await this.getColumnData(this.getColumnName(51), option);
- let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
- this.title = getCustomerName(this.corpType);
- allCropList({
- corpType: getCustomerCode(this.corpType),
- adminProfiles: userObj.role_name != "admin" ? userObj.user_id : null,
- corpsTypeName: this.treeType == "CK" ? "货代和物流" : null,
- belongtocompany: this.belongtocompany
- }).then(res => {
- this.corpList = res.data.data;
- });
- },
- mounted() {},
- methods: {
- init() {
- this.openDialog();
- },
- openDialog() {
- let _this = this;
- this.treeOption.treeLoad = function(node, resolve) {
- const parentId = node.level === 0 ? 0 : node.data.id;
- getDeptLazyTree({
- parentId: parentId,
- corpType: getCustomerCode(_this.corpType),
- cname: _this.treeType == "CK" ? "货代和物流" : null
- }).then(res => {
- resolve(
- res.data.data.map(item => {
- return {
- ...item,
- leaf: !item.hasChildren
- };
- })
- );
- });
- };
- this.corpVisible = true;
- },
- closed() {
- this.$refs.crud.toggleSelection();
- },
- importCorp() {
- if (this.multiple && this.selectionList.length == 0) return this.$message.error('请选择明细')
- this.$emit("balabala", this.selectionList[0].id);
- this.$emit("getCorpData", {
- ...this.selectionList[0],
- index: this.cropIndex
- });
- this.$emit("getCorpList", [...this.selectionList])
- this.corpVisible = false;
- },
- clear(){
- this.$emit("clear");
- },
- corpChange(row) {
- if (!this.multiple) {
- this.corpList.forEach(e => {
- if (row == e.id) {
- this.$emit("getCorpData", { ...e, index: this.cropIndex });
- }
- });
- } else {
- let arr = [];
- row.forEach(item => {
- let obj = {id: item};
- this.$set(obj, 'cname', this.corpList.find(e => e.id == item).cname);
- arr.push(obj)
- })
- this.$nextTick(() => {
- this.$emit('getCorpList', [...arr]);
- })
- }
- },
- refreshChange() {
- this.onLoad(this.page, this.search);
- },
- onLoad(page, params = { parentId: 0 }) {
- let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
- let queryParams = Object.assign({}, params, {
- size: page.pageSize,
- current: page.currentPage,
- corpsTypeId: this.treeDeptId,
- corpType: getCustomerCode(this.corpType),
- adminProfiles: userObj.role_name != "admin" ? userObj.user_id : null,
- corpsTypeName: this.treeType == "CK" ? "货代和物流" : null,
- belongtocompany: this.belongtocompany
- });
- this.loading = true;
- customerList(queryParams)
- .then(res => {
- this.data = res.data.data.records;
- this.page.total = res.data.data.total;
- if (this.page.total) {
- this.tableOption.height = window.innerHeight - 350;
- }
- })
- .finally(() => {
- this.loading = false;
- });
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- sizeChange(val) {
- this.page.pageSize = val;
- this.onLoad();
- },
- currentChange(val) {
- this.page.currentPage = val;
- this.onLoad();
- },
- //列表内展开树节点
- treeLoad(tree, treeNode, resolve) {
- const parentId = tree.id;
- customerList({ parentId: parentId }).then(res => {
- resolve(res.data.data.records);
- });
- },
- //点击搜索按钮触发
- searchChange(params, done) {
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- searchReset() {
- this.treeDeptId = null;
- },
- nodeClick(data) {
- this.treeDeptId = data.id;
- this.page.currentPage = 1;
- this.onLoad(this.page);
- },
- //列保存触发
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(51),
- this.option
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- async resetColumn() {
- this.option = option;
- const inSave = await this.delColumnData(this.getColumnName(51), option);
- if (inSave) {
- this.$message.success("重置成功");
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- // 更新数据
- updateData(belongToCompany) {
- let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
- allCropList({
- corpType: getCustomerCode(this.corpType),
- adminProfiles: !userObj.role_name.split(',').some(item => item == 'admin' || item == 'administrator') ? userObj.user_id : null,
- belongtocompany: belongToCompany,
- }).then(res => {
- this.corpList = res.data.data;
- });
- },
- }
- };
- </script>
- <style scoped lang="scss"></style>
|