| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874 | <template>  <div>    <div class="borderless">      <div class="customer-head">        <div class="customer-back">          <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left" @click="backToList"            >返回列表          </el-button>        </div>        <div class="add-customer-btn">          <el-button type="primary" size="small" @click="editCustomer">            保存数据          </el-button>          <el-button class="el-button--small-yh" :type="form.enableOrNot == 0 ? 'primary' : ''" size="small" v-if="form.id" @click="editEnable">            {{ form.enableOrNot == 0 ? "启用" : "禁用" }}          </el-button>        </div>      </div>      <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">        <avue-form ref="form" class="trading-form" v-model="form" :option="option">          <template slot="corpsTypeId">            <div style="display:flex;">              <avue-input-tree v-model="form.corpsTypeId" :disabled="option.disabled" placeholder="请选择客户分类" :dic="corpTypeList" :props="props">              </avue-input-tree>              <i class="el-icon-circle-plus-outline" style="font-size:18px;line-height: 32px;margin-left:4px" @click="corpTypeVisible = true"></i>            </div>          </template>        </avue-form>      </trade-card>      <trade-card title="客户联系人" v-loading="loadingBtn">        <avue-crud          ref="crudTwo"          :option="customerContactBack"          v-model="contactsForm"          :data="contactsData"          @row-save="rowSave"          @row-update="rowUpdate"          @row-del="rowDelTwo"        >          <template slot-scope="{ type, size, row, disabled, index }" slot="menu">            <el-button              :size="size"              :disabled="disabled"              :type="type"              :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'"              @click="$refs.crudTwo.rowEdit(row, index)"              >{{ row.$cellEdit ? "确认" : "修改" }}            </el-button>            <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type" @click="rowDelTwo(row, index)">删除 </el-button>            <el-button icon="el-icon-check" :size="size" :type="type" @click="creatingUsers(row)">创建用户 </el-button>          </template>        </avue-crud>      </trade-card>      <trade-card title="地址信息" v-loading="loadingBtn">        <avue-crud          :option="option2"          ref="crud"          :data="data"          @row-save="rowSave"          @row-update="rowUpdate"        >          <template slot="headerSerial">            <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow" :disabled="detailData.status == 1" circle></el-button>          </template>          <template slot="menuLeft">            <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="addRow">录入明细 </el-button>          </template>          <template v-if="!row.$cellEdit" slot-scope="{ type, size, row, index, disabled }" slot="menu">            <el-button              :size="size"              :disabled="disabled"              :type="type"              :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'"              @click="$refs.crud.rowCell(row, index)"              >{{ row.$cellEdit ? "确认" : "修改" }}            </el-button>            <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type" @click="rowDel(row, index)">删除 </el-button>          </template>          <template slot="defaultAddres" slot-scope="{ row, index, disabled }">            <el-switch active-value="1" inactive-value="0" :disabled="disabled" v-model="row.defaultAddres" @change="addressUnique(row, index)">            </el-switch>          </template>        </avue-crud>      </trade-card>      <containerTitle title="上传附件"></containerTitle>      <c-upload        v-loading="loadingBtn"        typeUpload="CD"        deleteUrl="/api/blade-sales-part/corpsfiles/remove"        :data="corpsFiles"        display        :enumerationValue="35.1"        :disabled="detailData.status == 1"      ></c-upload>      <el-dialog        title="设置客户分类"        v-dialogDrag        :visible.sync="corpTypeVisible"        class="avue-dialog"        width="80%"        append-to-body        @closed="corpTypeClosed"      >        <span>          <corp-type></corp-type>        </span>        <div class="avue-dialog__footer">          <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>          <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>        </div>      </el-dialog>    </div>    <el-dialog title="创建用户" :visible.sync="dialogVisibleBt" append-to-body width="60%">      <avue-form v-if="dialogVisibleBt" ref="formDataTwo" v-model="formDataTwo" :option="optionData"> </avue-form>      <span slot="footer" class="dialog-footer">        <el-button @click="dialogVisibleBt = false">取 消</el-button>        <el-button type="primary" @click="confirmSynchronizationTwo">确 定</el-button>      </span>    </el-dialog>  </div></template><script>import {  getDetails,  getCorpType,  submit,  customerList,  areaTypeTree,  itemDel,  corpsattn,  editenable,  getUserByRole,  getBrandDesc,  creatingUsersTwo} from "@/api/fc/customerInformation";import { getRoleTree } from "@/api/system/role";import { getDeptTree } from "@/api/system/dept";import { getPostList } from "@/api/system/post";import corpType from './components/index.vue'import website from "@/config/website";export default {  name: "index",  data() {    return {      propsCk: {        label: "cname",        value: "id"      },      props: {        label: "title",        value: "value"      },      optionData: {        span: 8,        menuBtn: false,        column: [          {            label: "所属角色",            prop: "roleId",            multiple: true,            type: "tree",            dicData: [],            props: {              label: "title"            },            checkStrictly: true,            slot: true,            rules: [              {                required: true,                message: "请选择所属角色",                trigger: "click"              }            ]          },          {            label: "所属部门",            prop: "deptId",            type: "tree",            multiple: true,            dicData: [],            props: {              label: "title"            },            checkStrictly: true,            slot: true,            rules: [              {                required: true,                message: "请选择所属部门",                trigger: "click"              }            ]          },          {            label: "所属岗位",            prop: "postId",            type: "tree",            multiple: true,            dicData: [],            props: {              label: "postName",              value: "id"            },            rules: [              {                required: true,                message: "请选择所属岗位",                trigger: "click"              }            ]          }        ]      },      dialogVisibleBt: false,      formDataTwo: false,      customerContact: {},      contactsForm: {},      contactsData: [],      corpTypeList: [],      corpTypeVisible: false,      loadingBtn: false,      form: {        ifLimitAmount: "0"      },      form4: {},      data: [],      data2: [],      option: {        menuBtn: false,        labelWidth: 130,        column: [          {            label: "客户名称",            prop: "cname",            rules: [              {                required: true,                message: "",                trigger: "blur"              }            ],            span: 8          },          {            label: "客户分类",            prop: "corpsTypeId",            span: 8,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "电话",            prop: "tel",            span: 8          },          {            label: "业务员",            span: 12,            prop: "salesmanId",            type: "select",            props: {              label: "name",              value: "id"            },            dicData: [],            dicUrl: "/api/blade-user/factoryUserList",            filterable: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ],            // change: value => {            //   if (value.value) {            //     for (let item of value.column.dicData.data) {            //       if (item.id == value.value) {            //         this.$set(this.form, "salesmanName", item.name);            //       }            //     }            //   }            // }          },          {            label: "品牌",            prop: "brandId",            props: {              label: "cname",              value: "id"            },            span: 12,            search: true,            dicDate: [],            multiple: true,            dicUrl: "/api/gubersail-admin/brandDesc/listAllV1?type=PP",            type: "select",            dataType: "string",            rules: [              {                message: "请选择品牌",                trigger: "click"              }            ]          },          {            label: "备注",            prop: "remarks",            type: "textarea",            minRows: 2,            span: 24          }        ]      },      option2: {        align: "center",        index: true,        addBtnText: "录入明细",        refreshBtn: false,        dialogDrag: true,        addBtn: false,        span: 8,        height: 300,        editBtn: false,        delBtn: false,        menuWidth: 140,        dialogTop: 25,        dialogWidth: "80%",        addRowBtn: false,        cellBtn: true,        rowKey: "index",        cancelBtn: false,        columnBtn:false,        // saveBtn:false,        column: [          {            label: "联系人",            prop: "contacts",            cell: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "电话",            prop: "tel",            cell: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "地址",            prop: "belongtoarea",            dicData: [],            dataType: "string",            type: "cascader",            props: {              label: "name",              value: "name"            },            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ],            filterable: true,            cell: true          },          {            label: "详细地址",            prop: "detailedAddress",            cell: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "备注",            prop: "remarks",            cell: true          },          {            label: "默认地址",            prop: "defaultAddres",            display: false,            width: 100          }        ]      },      option3: {},      option4: {        menuBtn: false,        labelWidth: 80,        column: [          {            label: "分类名称",            prop: "cname",            rules: [              {                required: true,                message: "",                trigger: "blur"              }            ],            span: 24          },          {            label: "上级类型",            prop: "parentId",            dicData: [],            type: "tree",            props: {              label: "cname",              value: "id"            },            span: 24          }        ]      },      corpsFiles: [],      customerContactBack: {        align: "center",        index: true,        addBtnText: "录入明细",        refreshBtn: false,        dialogDrag: true,        addBtn: true,        span: 8,        height: 300,        addRowBtn: false,        editBtn: false,        delBtn: false,        menuWidth: 200,        dialogTop: 25,        dialogWidth: "80%",        columnBtn:false,        column: [          {            label: "联系人",            prop: "cname",            cell: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "电话",            prop: "tel",            cell: true,            rules: [              {                required: true,                message: " ",                trigger: "blur"              }            ]          },          {            label: "登录用户id",            prop: "userId",            cell: true          },          {            label: "备注",            prop: "remarks",            cell: true          }        ]      },      userObj: {}    };  },  components: { corpType },  props: {    detailData: {      type: Object    }  },  async created() {    if (this.detailData.id) {      this.getDetail(this.detailData.id);    }    if (this.detailData.status == 1) {      this.option.disabled = true;    }    if (!website.tenantMode) {      this.initData(website.tenantId);    } else {      this.initData();    }    this.getUserByRolefun();    this.getCorpType();    this.getAllWorkDicts();    this.userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;  },  activated() {    setTimeout(() => {      this.$nextTick(() => {        this.$refs.crud.doLayout();      });    }, 100);  },  methods: {    // 获取业务员数据    getUserByRolefun() {      getUserByRole().then(res => {        this.findObject(this.option.column, "salesmanId").dicData = res.data;      });    },    // 启用或禁用    editEnable() {      let data = this.form;      editenable({ id: data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {        this.$message({          type: "success",          message: data.enableOrNot ? "禁用成功!" : "启用成功!"        });        this.getDetail(this.detailData.id);        // this.$set(this.form, 'enableOrNot', data.enableOrNot == 1 ? 0 : 1)      });    },    addressUnique(row, index) {      for (let item in this.data) {        if (index != item) {          if (this.data[item].defaultAddres == 1) {            this.$message.warning("默认地址只能唯一");            return (row.defaultAddres = 0);          }        }      }    },    initData(tenantId) {      getBrandDesc().then(res => {        const column = this.findObject(this.option.column, "brandId");        column.dicData = res.data.data;        this.form.brandId = "";      });      getRoleTree(tenantId).then(res => {        const column = this.findObject(this.optionData.column, "roleId");        column.dicData = res.data.data;      });      getDeptTree(tenantId).then(res => {        const column = this.findObject(this.optionData.column, "deptId");        column.dicData = res.data.data;      });      getPostList(tenantId).then(res => {        const column = this.findObject(this.optionData.column, "postId");        column.dicData = res.data.data;      });    },    //确认创建用户    confirmSynchronizationTwo() {      this.$refs.formDataTwo.validate((valid, done) => {        done();        if (valid) {          let data = JSON.parse(JSON.stringify(this.formDataTwo));          data.deptId = data.deptId.join(",");          data.roleId = data.roleId.join(",");          data.postId = data.postId.join(",");          creatingUsersTwo({            ...data,            id: this.formRow.id          }).then(res => {            this.dialogVisibleBt = false;            this.formDataTwo = {};            this.$message.success("创建用户成功,默认帐号:手机号。默认密码:123456");            this.getDetail(this.form.id);          });        } else {          return false;        }      });    },    getAllWorkDicts() {      customerList({ corpType: "KH" }).then(res => {        this.findObject(this.option4.column, "parentId").dicData = res.data.data.records;      });      this.getWorkDicts("abbreviation").then(res => {        this.findObject(this.option2.column, "abbreviation").dicData = res.data.data;      });      this.getAreaData();      this.findObject(this.option2.column, "belongtoarea").dicData = JSON.parse(localStorage.getItem('areaTypeTree'))      this.$refs.crud.init();    },    getAreaData() {      areaTypeTree().then(res => {});    },    getDetail(id) {      this.loadingBtn = true;      getDetails({ id: id })        .then(res => {          this.form = res.data.data;          if (this.form.enableOrNot == 1) {            this.$set(this.option, "disabled", true);          } else {            this.$set(this.option, "disabled", false);          }          if (this.form.brandId == null || this.form.brandId === "") {            this.form.brandId = "";          }          this.data = res.data.data.corpsAddrList;          this.corpsFiles = res.data.data.corpsFilesList;          this.contactsData = res.data.data.corpsAttnList;        })        .finally(() => {          this.loadingBtn = false;        });    },    addRow() {      this.data.push({ $cellEdit: true });    },    rowDel(row, index) {      this.$confirm("确定删除数据?", {        confirmButtonText: "确定",        cancelButtonText: "取消",        type: "warning"      }).then(() => {        if (row.id) {          itemDel(row.id).then(res => {            this.$message({              type: "success",              message: "删除成功!"            });            this.data.splice(index, 1);          });        } else {          this.$message({            type: "success",            message: "删除成功!"          });          this.data.splice(index, 1);        }      });    },    addRow2() {      this.data2.push({ $cellEdit: true, type: 1 });    },    rowCell2(row, index) {      if (row.$cellEdit == true) {        this.$set(row, "$cellEdit", false);      } else {        this.$set(row, "$cellEdit", true);      }    },    rowDe2(row, index) {      this.$confirm("确定删除数据?", {        confirmButtonText: "确定",        cancelButtonText: "取消",        type: "warning"      }).then(() => {        if (row.id) {          // itemDel(row.id).then(res => {          //   this.$message({          //     type: "success",          //     message: "删除成功!"          //   });          //   this.data2.splice(index, 1);          // });        } else {          this.$message({            type: "success",            message: "删除成功!"          });          this.data2.splice(index, 1);        }      });    },    corpTypeClosed() {      // this.reload = Math.random();      // this.form4 = this.$options.data().form4    },    getCorpType() {      getCorpType({ corpType: "KH" }).then(res => {        this.corpTypeList = res.data.data;      });    },    addCorpType() {      this.getCorpType();      this.corpTypeVisible = false;    },    //修改提交触发    editCustomer() {      this.$refs.form.validate((valid, done) => {        done();        if (valid) {          if (this.contactsData.length == 0) return this.$message.error("请添加客户联系人");          if (this.data.length == 0) return this.$message.error("请添加地址信息");          this.loadingBtn = true;          if (!this.form.id) {            this.form.checkStatus = "通过";            // typeof(this.form.brandId) == 'Array' ? this.form.prandId.join(',') : this.form.brandId = ''          }          console.log(this.form.$brandId);          if (this.form.$brandId) {            this.form.brandName = this.form.$brandId.split("|").join(",");          } else {            this.form.brandName = null;          }          submit({            ...this.form,            code: this.form.cname,            corpType: "KH",            corpsAddrList: this.data,            corpsFilesList: this.corpsFiles,            corpsAttnList: this.contactsData,            billType: 1          })            .then(res => {              this.$message.success("保存成功");              this.form = res.data.data;              this.data = res.data.data.corpsAddrList;              this.corpsFiles = res.data.data.corpsFilesList;              this.getDetail(res.data.data.id);              if (!this.form.id) {                //添加成功后默认启用                let data = this.form;                editenable({ id: res.data.data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {                  this.$set(this.form, "enableOrNot", data.enableOrNot == 1 ? 0 : 1);                });              }            })            .finally(() => {              this.loadingBtn = false;            });        } else {          return false;        }      });    },    creatingUsers(row) {      console.log("row", row);      if (row.id) {        if (row.tel) {          if (!row.userId) {            this.dialogVisibleBt = true;            this.formDataTwo = {              roleId: ["1658417787548205058"],              postId: ["1742709504333688834"],              deptId: [this.userObj.dept_id]            };            this.formRow = row;          } else {            this.$message.error("已经存在用户,请勿重复创建");          }        } else {          this.$message.error("请输入手机号");        }      } else {        this.$message.error("请保存数据后再点击");      }    },    //新增客户联系人保存触发    rowSave(row, done, loading) {      if (this.data.length == 1) {        this.$set(row, "defaultAddres", "1");      }      done(row);    },    //修改客户联系人触发    rowUpdate(row, index, done, loading) {      done(row);    },    //删除客户联系人触发    rowDelTwo(row, index, donerowDel) {      this.$confirm("确定将选择数据删除?", {        confirmButtonText: "确定",        cancelButtonText: "取消",        type: "warning"      }).then(() => {        // 数据回调进行刷新        if (row.id) {          corpsattn(row.id).then(res => {            this.$message({              type: "success",              message: "操作成功!"            });            this.contactsData.splice(index, 1);          });        } else {          this.$message({            type: "success",            message: "操作成功!"          });          this.contactsData.splice(index, 1);        }      });    },    //返回列表    backToList() {      this.$emit("goBack");    }  }};</script><style lang="scss" scoped>.trading-form ::v-deep .el-form-item {  margin-bottom: 8px !important;}::v-deep .el-dialog__body {  padding: 0px 20px 15px 20px;}::v-deep .el-form-item__error {  display: none !important;}.el-dialog ::v-deep .el-form-item__error {  display: none !important;}.img-form ::v-deep .el-form-item {  height: 150px;  line-height: 150px;  margin-bottom: 8px !important;}.img-form ::v-deep .avue-upload__icon {  font-size: 20px;  width: 150px;  height: 150px;  line-height: 150px;}::v-deep .el-table .cell {  padding: 0 2px !important;}::v-deep .avue-crud .el-table .el-form-item__label {  left: -1px;}.addressTabs {  display: flex;  justify-content: center;  span {    width: 100px;    font-size: 18px;    font-weight: 600;    text-align: center;  }}</style>
 |