customerCheck.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div>
  3. <el-button
  4. size="small"
  5. type="primary"
  6. @click="isCheck"
  7. class="inline-16 normal-btn-width"
  8. >{{ $t("查 重") }}</el-button
  9. >
  10. <el-dialog
  11. :title="$t('重复客户')"
  12. :visible.sync="dialogTableVisible"
  13. append-to-body
  14. width="1000px"
  15. @close="dialogTableVisible = false"
  16. >
  17. <div slot="title" class="dialog-title">
  18. <span class="title-text">{{ $t("重复客户") }}</span>
  19. <p style="font-size: 14px; color: red">
  20. {{ $t("已存在重复客户不可继续创建") }}
  21. </p>
  22. </div>
  23. <tableLayout
  24. :layout="tablecols"
  25. :data="list"
  26. :opwidth="200"
  27. height="calc(100vh - 550px)"
  28. :width="true"
  29. :custom="true"
  30. >
  31. <template v-slot:customcol="scope">
  32. <div v-if="scope.column.columnname === 'tag'">
  33. <div
  34. v-for="item in scope.column.data.tag_sys"
  35. :key="item.index"
  36. style="float: left; margin-left: 5px; margin-bottom: 5px"
  37. >
  38. <el-tag color="#3874F6" size="mini" type="primary" effect="dark">
  39. <span>{{ $t(item) }}</span>
  40. </el-tag>
  41. </div>
  42. <div
  43. v-for="item in scope.column.data.tag"
  44. :key="item.index"
  45. style="float: left; margin-left: 5px; margin-bottom: 5px"
  46. >
  47. <el-tag color="#FA8C16" size="mini" type="warning" effect="dark">
  48. <span>{{ $t(item) }}</span>
  49. </el-tag>
  50. </div>
  51. </div>
  52. <div v-else-if="scope.column.columnname === 'leader'">
  53. <span>{{
  54. scope.column.data.leader
  55. ? scope.column.data.leader.length !== 0
  56. ? scope.column.data.leader[0].name
  57. : "--"
  58. : "--"
  59. }}</span>
  60. </div>
  61. <p v-else>
  62. <span v-if="scope.column.data[scope.column.columnname]">
  63. <span :style="{color:scope.column.data.chars[0][scope.column.columnname] && scope.column.data[scope.column.columnname].includes(scope.column.data.chars[0][scope.column.columnname])?'red':'#666'}">
  64. {{scope.column.data[scope.column.columnname]}}
  65. </span>
  66. </span>
  67. <span v-else>
  68. --
  69. </span>
  70. </p>
  71. </template>
  72. </tableLayout>
  73. <div class="container normal-panel" style="text-align: right">
  74. <el-pagination
  75. background
  76. @size-change="handleSizeChange"
  77. @current-change="handleCurrentChange"
  78. :current-page="currentPage"
  79. :page-sizes="[20, 50, 100, 200]"
  80. :page-size="20"
  81. layout="total,sizes, prev, pager, next, jumper"
  82. :total="total"
  83. ></el-pagination>
  84. </div>
  85. <span slot="footer" class="dialog-footer" v-if="creatShow">
  86. <div
  87. style="display: flex; justify-content: space-between"
  88. v-if="isBack"
  89. >
  90. <div style="color: red" v-if="isBack">
  91. {{ $t("当前有重复客户归属回收站,请联系管理处理") }}
  92. </div>
  93. <el-button
  94. @click="dialogTableVisible = false"
  95. size="small"
  96. type="primary"
  97. class="normal-btn-width"
  98. >{{ $t("确 定") }}</el-button
  99. >
  100. </div>
  101. <el-button
  102. v-else
  103. @click="dialogTableVisible = false"
  104. size="small"
  105. type="primary"
  106. class="normal-btn-width"
  107. >{{ $t("确 定") }}</el-button
  108. >
  109. </span>
  110. <span slot="footer" class="dialog-footer" v-if="isBack && !creatShow">
  111. <div style="display: flex; justify-content: space-between">
  112. <div style="color: red">
  113. {{ $t("当前有重复客户归属回收站,请联系管理处理") }}
  114. </div>
  115. <el-button
  116. @click="
  117. dialogTableVisible = false;
  118. isBack = false;
  119. "
  120. size="small"
  121. type="primary"
  122. class="normal-btn-width"
  123. >{{ $t("确 定") }}</el-button
  124. >
  125. </div>
  126. </span>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. export default {
  132. name: "customerCheck",
  133. props: ["data"],
  134. data() {
  135. return {
  136. dialogTableVisible: false,
  137. list: [],
  138. tablecols: [],
  139. total: 0,
  140. currentPage: 0,
  141. duplicates: false,
  142. creatShow: false,
  143. isBack: false,
  144. message: "该客户疑似重复,是否确认创建客户?",
  145. buttonTitle: "确定创建",
  146. param: {
  147. id: 20221208172002,
  148. content: {
  149. sa_customersid: "",
  150. enterprisename: "",
  151. taxno: "",
  152. address: "",
  153. },
  154. },
  155. fields1: [],
  156. fields2: [],
  157. fields3: [],
  158. };
  159. },
  160. methods: {
  161. async listData() {
  162. this.param.content.sa_customersid = this.data.sa_customersid || 0;
  163. this.fields1.forEach((item) => {
  164. this.param.content[item] = this.data[item] || "";
  165. });
  166. this.fields2.forEach((item) => {
  167. this.param.content[item] = this.data[item] || "";
  168. });
  169. this.fields3.forEach((item) => {
  170. this.param.content[item] = this.data[item] || "";
  171. });
  172. const res = await this.$api.requested(this.param);
  173. if (res.code == 0) {
  174. this.tool.showMessage(res);
  175. } else {
  176. if (res.total > 0) {
  177. this.list = res.data;
  178. this.total = res.total;
  179. this.currentPage = res.pageNumber;
  180. this.list.forEach((item) => {
  181. this.isBack = false;
  182. if (item.systemapp === "回收站") {
  183. this.isBack = true;
  184. }
  185. });
  186. this.dialogTableVisible = true;
  187. } else {
  188. if (this.creatShow) {
  189. this.onSubmit();
  190. } else {
  191. this.$message({
  192. message: this.$t("无重复数据"),
  193. type: "success",
  194. });
  195. }
  196. }
  197. }
  198. },
  199. onCheck() {
  200. if (this.buttonTitle === "确定保存") {
  201. this.message = "该客户疑似重复,是否确认更新客户?";
  202. } else {
  203. this.message = "该客户疑似重复,是否确认创建客户?";
  204. }
  205. this.$confirm(this.$t(this.message), this.$t("提示"), {
  206. confirmButtonText: this.$t("确定"),
  207. cancelButtonText: this.$t("取消"),
  208. type: "warning",
  209. })
  210. .then(() => {
  211. this.duplicates = true;
  212. this.onSubmit();
  213. })
  214. .catch(() => {
  215. this.$message({
  216. type: "info",
  217. message: this.$t("已取消"),
  218. });
  219. });
  220. },
  221. async onSubmit() {
  222. if (this.data.contactsinfo.telephone) {
  223. this.data.contactsinfo.phonenumber = this.data.contactsinfo.telephone;
  224. this.data.contactsinfo.telephone = "";
  225. }
  226. const res = await this.$api.requested({
  227. id: 20221012163902,
  228. content: this.data,
  229. });
  230. this.tool.showMessage(res, () => {
  231. if (this.duplicates) {
  232. if (this.buttonTitle === "确定保存") {
  233. this.tagData(res.data.sa_customersid);
  234. } else {
  235. let data = ["疑似重复"];
  236. this.setTag(res.data.sa_customersid, data);
  237. }
  238. } else {
  239. this.$emit("onSuccess");
  240. /* this.setTag(res.data.sa_customersid,'')*/
  241. }
  242. });
  243. },
  244. async setTag(id, data) {
  245. const res = await this.$api.requested({
  246. id: 20220929090901,
  247. content: {
  248. ownertable: "sa_customers",
  249. ownerid: id,
  250. datatag: data,
  251. },
  252. });
  253. this.dialogTableVisible = false;
  254. this.duplicates = false;
  255. this.$emit("onSuccess");
  256. },
  257. // 获取标签数据
  258. async tagData(id) {
  259. const res = await this.$api.requested({
  260. content: {
  261. ownertable: "sa_customers",
  262. ownerid: this.$route.query.id,
  263. },
  264. id: 20220929085401,
  265. });
  266. var resTagData = [];
  267. resTagData = res.data.datatag;
  268. if (this.duplicates) {
  269. let flag = 0;
  270. for (var i = 0; i < res.data.datatag.length; i++) {
  271. if (res.data.datatag[i] === "疑似重复") {
  272. flag = 1;
  273. break;
  274. }
  275. }
  276. if (flag === 1) {
  277. this.setTag(id, resTagData);
  278. } else {
  279. resTagData.push("疑似重复");
  280. this.setTag(id, resTagData);
  281. }
  282. } else {
  283. for (var k = 0; k < res.data.datatag.length; k++) {
  284. if (res.data.datatag[k] === "疑似重复") {
  285. resTagData.splice(k);
  286. break;
  287. }
  288. }
  289. this.setTag(id, resTagData);
  290. }
  291. },
  292. handleSizeChange(val) {
  293. // console.log(`每页 ${val} 条`);
  294. this.param.content.pageSize = val;
  295. this.listData();
  296. },
  297. handleCurrentChange(val) {
  298. // console.log(`当前页: ${val}`);
  299. this.param.content.pageNumber = val;
  300. this.listData();
  301. },
  302. /*查询规则*/
  303. isCheck() {
  304. this.$emit("onCheck");
  305. },
  306. async queryRule() {
  307. const res = await this.$api.requested({
  308. id: "20230410090502",
  309. content: {},
  310. });
  311. this.fields1 = res.data.custcheckrule.fields1;
  312. this.fields2 = res.data.custcheckrule.fields2;
  313. this.fields3 = res.data.custcheckrule.fields3;
  314. this.listData();
  315. },
  316. },
  317. created() {
  318. this.tablecols = this.tool.tabelCol(
  319. this.$route.name
  320. ).duplicatesCustomerTable.tablecols;
  321. },
  322. };
  323. </script>
  324. <style scoped>
  325. /deep/ .el-dialog__body {
  326. padding: 20px 20px 0 20px !important;
  327. }
  328. </style>