customerCheck.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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.list.forEach((item) => {
  178. this.isBack = false;
  179. if (item.systemapp === "回收站") {
  180. this.isBack = true;
  181. }
  182. });
  183. this.dialogTableVisible = true;
  184. } else {
  185. if (this.creatShow) {
  186. this.onSubmit();
  187. } else {
  188. this.$message({
  189. message: this.$t("无重复数据"),
  190. type: "success",
  191. });
  192. }
  193. }
  194. }
  195. },
  196. onCheck() {
  197. if (this.buttonTitle === "确定保存") {
  198. this.message = "该客户疑似重复,是否确认更新客户?";
  199. } else {
  200. this.message = "该客户疑似重复,是否确认创建客户?";
  201. }
  202. this.$confirm(this.$t(this.message), this.$t("提示"), {
  203. confirmButtonText: this.$t("确定"),
  204. cancelButtonText: this.$t("取消"),
  205. type: "warning",
  206. })
  207. .then(() => {
  208. this.duplicates = true;
  209. this.onSubmit();
  210. })
  211. .catch(() => {
  212. this.$message({
  213. type: "info",
  214. message: this.$t("已取消"),
  215. });
  216. });
  217. },
  218. async onSubmit() {
  219. if (this.data.contactsinfo.telephone) {
  220. this.data.contactsinfo.phonenumber = this.data.contactsinfo.telephone;
  221. this.data.contactsinfo.telephone = "";
  222. }
  223. const res = await this.$api.requested({
  224. id: 20221012163902,
  225. content: this.data,
  226. });
  227. this.tool.showMessage(res, () => {
  228. if (this.duplicates) {
  229. if (this.buttonTitle === "确定保存") {
  230. this.tagData(res.data.sa_customersid);
  231. } else {
  232. let data = ["疑似重复"];
  233. this.setTag(res.data.sa_customersid, data);
  234. }
  235. } else {
  236. this.$emit("onSuccess");
  237. /* this.setTag(res.data.sa_customersid,'')*/
  238. }
  239. });
  240. },
  241. async setTag(id, data) {
  242. const res = await this.$api.requested({
  243. id: 20220929090901,
  244. content: {
  245. ownertable: "sa_customers",
  246. ownerid: id,
  247. datatag: data,
  248. },
  249. });
  250. this.dialogTableVisible = false;
  251. this.duplicates = false;
  252. this.$emit("onSuccess");
  253. },
  254. // 获取标签数据
  255. async tagData(id) {
  256. const res = await this.$api.requested({
  257. content: {
  258. ownertable: "sa_customers",
  259. ownerid: this.$route.query.id,
  260. },
  261. id: 20220929085401,
  262. });
  263. var resTagData = [];
  264. resTagData = res.data.datatag;
  265. if (this.duplicates) {
  266. let flag = 0;
  267. for (var i = 0; i < res.data.datatag.length; i++) {
  268. if (res.data.datatag[i] === "疑似重复") {
  269. flag = 1;
  270. break;
  271. }
  272. }
  273. if (flag === 1) {
  274. this.setTag(id, resTagData);
  275. } else {
  276. resTagData.push("疑似重复");
  277. this.setTag(id, resTagData);
  278. }
  279. } else {
  280. for (var k = 0; k < res.data.datatag.length; k++) {
  281. if (res.data.datatag[k] === "疑似重复") {
  282. resTagData.splice(k);
  283. break;
  284. }
  285. }
  286. this.setTag(id, resTagData);
  287. }
  288. },
  289. handleSizeChange(val) {
  290. // console.log(`每页 ${val} 条`);
  291. this.param.content.pageSize = val;
  292. this.listData();
  293. },
  294. handleCurrentChange(val) {
  295. // console.log(`当前页: ${val}`);
  296. this.param.content.pageNumber = val;
  297. this.listData();
  298. },
  299. /*查询规则*/
  300. isCheck() {
  301. this.$emit("onCheck");
  302. },
  303. async queryRule() {
  304. const res = await this.$api.requested({
  305. id: "20230410090502",
  306. content: {},
  307. });
  308. this.fields1 = res.data.custcheckrule.fields1;
  309. this.fields2 = res.data.custcheckrule.fields2;
  310. this.fields3 = res.data.custcheckrule.fields3;
  311. this.listData();
  312. },
  313. },
  314. created() {
  315. this.tablecols = this.tool.tabelCol(
  316. this.$route.name
  317. ).duplicatesCustomerTable.tablecols;
  318. },
  319. };
  320. </script>
  321. <style scoped>
  322. /deep/ .el-dialog__body {
  323. padding: 20px 20px 0 20px !important;
  324. }
  325. </style>