123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <div>
- <el-button
- size="small"
- type="primary"
- @click="isCheck"
- class="inline-16 normal-btn-width"
- >{{ $t("查 重") }}</el-button
- >
- <el-dialog
- :title="$t('重复客户')"
- :visible.sync="dialogTableVisible"
- append-to-body
- width="1000px"
- @close="dialogTableVisible = false"
- >
- <div slot="title" class="dialog-title">
- <span class="title-text">{{ $t("重复客户") }}</span>
- <p style="font-size: 14px; color: red">
- {{ $t("已存在重复客户不可继续创建") }}
- </p>
- </div>
- <tableLayout
- :layout="tablecols"
- :data="list"
- :opwidth="200"
- height="calc(100vh - 550px)"
- :width="true"
- :custom="true"
- >
- <template v-slot:customcol="scope">
- <div v-if="scope.column.columnname === 'tag'">
- <div
- v-for="item in scope.column.data.tag_sys"
- :key="item.index"
- style="float: left; margin-left: 5px; margin-bottom: 5px"
- >
- <el-tag color="#3874F6" size="mini" type="primary" effect="dark">
- <span>{{ $t(item) }}</span>
- </el-tag>
- </div>
- <div
- v-for="item in scope.column.data.tag"
- :key="item.index"
- style="float: left; margin-left: 5px; margin-bottom: 5px"
- >
- <el-tag color="#FA8C16" size="mini" type="warning" effect="dark">
- <span>{{ $t(item) }}</span>
- </el-tag>
- </div>
- </div>
- <div v-else-if="scope.column.columnname === 'leader'">
- <span>{{
- scope.column.data.leader
- ? scope.column.data.leader.length !== 0
- ? scope.column.data.leader[0].name
- : "--"
- : "--"
- }}</span>
- </div>
- <p v-else>
- {{
- scope.column.data[scope.column.columnname]
- ? scope.column.data[scope.column.columnname]
- : "--"
- }}
- </p>
- </template>
- </tableLayout>
- <div class="container normal-panel" style="text-align: right">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[20, 50, 100, 200]"
- :page-size="20"
- layout="total,sizes, prev, pager, next, jumper"
- :total="total"
- ></el-pagination>
- </div>
- <span slot="footer" class="dialog-footer" v-if="creatShow">
- <div
- style="display: flex; justify-content: space-between"
- v-if="isBack"
- >
- <div style="color: red" v-if="isBack">
- {{ $t("当前有重复客户归属回收站,请联系管理处理") }}
- </div>
- <el-button
- @click="dialogTableVisible = false"
- size="small"
- type="primary"
- class="normal-btn-width"
- >{{ $t("确 定") }}</el-button
- >
- </div>
- <el-button
- v-else
- @click="dialogTableVisible = false"
- size="small"
- type="primary"
- class="normal-btn-width"
- >{{ $t("确 定") }}</el-button
- >
- </span>
- <span slot="footer" class="dialog-footer" v-if="isBack && !creatShow">
- <div style="display: flex; justify-content: space-between">
- <div style="color: red">
- {{ $t("当前有重复客户归属回收站,请联系管理处理") }}
- </div>
- <el-button
- @click="
- dialogTableVisible = false;
- isBack = false;
- "
- size="small"
- type="primary"
- class="normal-btn-width"
- >{{ $t("确 定") }}</el-button
- >
- </div>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- name: "customerCheck",
- props: ["data"],
- data() {
- return {
- dialogTableVisible: false,
- list: [],
- tablecols: [],
- total: 0,
- currentPage: 0,
- duplicates: false,
- creatShow: false,
- isBack: false,
- message: "该客户疑似重复,是否确认创建客户?",
- buttonTitle: "确定创建",
- param: {
- id: 20221208172002,
- content: {
- sa_customersid: "",
- enterprisename: "",
- taxno: "",
- address: "",
- },
- },
- fields1: [],
- fields2: [],
- fields3: [],
- };
- },
- methods: {
- async listData() {
- this.param.content.sa_customersid = this.data.sa_customersid || 0;
- this.fields1.forEach((item) => {
- this.param.content[item] = this.data[item] || "";
- });
- this.fields2.forEach((item) => {
- this.param.content[item] = this.data[item] || "";
- });
- this.fields3.forEach((item) => {
- this.param.content[item] = this.data[item] || "";
- });
- const res = await this.$api.requested(this.param);
- if (res.code == 0) {
- this.tool.showMessage(res);
- } else {
- if (res.total > 0) {
- this.list = res.data;
- this.total = res.total;
- this.currentPage = res.pageNumber;
- this.list.forEach((item) => {
- this.isBack = false;
- if (item.systemapp === "回收站") {
- this.isBack = true;
- }
- });
- this.dialogTableVisible = true;
- } else {
- if (this.creatShow) {
- this.onSubmit();
- } else {
- this.$message({
- message: this.$t("无重复数据"),
- type: "success",
- });
- }
- }
- }
- },
- onCheck() {
- if (this.buttonTitle === "确定保存") {
- this.message = "该客户疑似重复,是否确认更新客户?";
- } else {
- this.message = "该客户疑似重复,是否确认创建客户?";
- }
- this.$confirm(this.$t(this.message), this.$t("提示"), {
- confirmButtonText: this.$t("确定"),
- cancelButtonText: this.$t("取消"),
- type: "warning",
- })
- .then(() => {
- this.duplicates = true;
- this.onSubmit();
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: this.$t("已取消"),
- });
- });
- },
- async onSubmit() {
- if (this.data.contactsinfo.telephone) {
- this.data.contactsinfo.phonenumber = this.data.contactsinfo.telephone;
- this.data.contactsinfo.telephone = "";
- }
- const res = await this.$api.requested({
- id: 20221012163902,
- content: this.data,
- });
- this.tool.showMessage(res, () => {
- if (this.duplicates) {
- if (this.buttonTitle === "确定保存") {
- this.tagData(res.data.sa_customersid);
- } else {
- let data = ["疑似重复"];
- this.setTag(res.data.sa_customersid, data);
- }
- } else {
- this.$emit("onSuccess");
- /* this.setTag(res.data.sa_customersid,'')*/
- }
- });
- },
- async setTag(id, data) {
- const res = await this.$api.requested({
- id: 20220929090901,
- content: {
- ownertable: "sa_customers",
- ownerid: id,
- datatag: data,
- },
- });
- this.dialogTableVisible = false;
- this.duplicates = false;
- this.$emit("onSuccess");
- },
- // 获取标签数据
- async tagData(id) {
- const res = await this.$api.requested({
- content: {
- ownertable: "sa_customers",
- ownerid: this.$route.query.id,
- },
- id: 20220929085401,
- });
- var resTagData = [];
- resTagData = res.data.datatag;
- if (this.duplicates) {
- let flag = 0;
- for (var i = 0; i < res.data.datatag.length; i++) {
- if (res.data.datatag[i] === "疑似重复") {
- flag = 1;
- break;
- }
- }
- if (flag === 1) {
- this.setTag(id, resTagData);
- } else {
- resTagData.push("疑似重复");
- this.setTag(id, resTagData);
- }
- } else {
- for (var k = 0; k < res.data.datatag.length; k++) {
- if (res.data.datatag[k] === "疑似重复") {
- resTagData.splice(k);
- break;
- }
- }
- this.setTag(id, resTagData);
- }
- },
- handleSizeChange(val) {
- // console.log(`每页 ${val} 条`);
- this.param.content.pageSize = val;
- this.listData();
- },
- handleCurrentChange(val) {
- // console.log(`当前页: ${val}`);
- this.param.content.pageNumber = val;
- this.listData();
- },
- /*查询规则*/
- isCheck() {
- this.$emit("onCheck");
- },
- async queryRule() {
- const res = await this.$api.requested({
- id: "20230410090502",
- content: {},
- });
- this.fields1 = res.data.custcheckrule.fields1;
- this.fields2 = res.data.custcheckrule.fields2;
- this.fields3 = res.data.custcheckrule.fields3;
- this.listData();
- },
- },
- created() {
- this.tablecols = this.tool.tabelCol(
- this.$route.name
- ).duplicatesCustomerTable.tablecols;
- },
- };
- </script>
- <style scoped>
- /deep/ .el-dialog__body {
- padding: 20px 20px 0 20px !important;
- }
- </style>
|