customerCheck.vue 9.3 KB

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