customerChangeCheck.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. >
  16. <div slot="title" class="dialog-title">
  17. <span class="title-text">{{ $t("重复客户") }}</span>
  18. <p style="font-size: 14px; color: red">
  19. {{ $t("已存在重复客户不可继续创建") }}
  20. </p>
  21. </div>
  22. <tableLayout
  23. :layout="tablecols"
  24. :data="list"
  25. :opwidth="200"
  26. height="calc(100vh - 550px)"
  27. :width="true"
  28. :custom="true"
  29. >
  30. <template v-slot:customcol="scope">
  31. <div v-if="scope.column.columnname === 'tag'">
  32. <div
  33. v-for="item in scope.column.data.tag_sys"
  34. :key="item.index"
  35. style="float: left; margin-left: 5px; margin-bottom: 5px"
  36. >
  37. <el-tag color="#3874F6" size="mini" type="primary" effect="dark">
  38. <span>{{ $t(item) }}</span>
  39. </el-tag>
  40. </div>
  41. <div
  42. v-for="item in scope.column.data.tag"
  43. :key="item.index"
  44. style="float: left; margin-left: 5px; margin-bottom: 5px"
  45. >
  46. <el-tag color="#FA8C16" size="mini" type="warning" effect="dark">
  47. <span>{{ $t(item) }}</span>
  48. </el-tag>
  49. </div>
  50. </div>
  51. <div v-else-if="scope.column.columnname === 'leader'">
  52. <span>{{
  53. scope.column.data.leader
  54. ? scope.column.data.leader.length !== 0
  55. ? scope.column.data.leader[0].name
  56. : "--"
  57. : "--"
  58. }}</span>
  59. </div>
  60. <p v-else>
  61. <span v-if="scope.column.data[scope.column.columnname]">
  62. <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'}">
  63. {{scope.column.data[scope.column.columnname]}}
  64. </span>
  65. </span>
  66. <span v-else>
  67. --
  68. </span>
  69. </p>
  70. </template>
  71. </tableLayout>
  72. <div class="container normal-panel" style="text-align: right">
  73. <el-pagination
  74. background
  75. @size-change="handleSizeChange"
  76. @current-change="handleCurrentChange"
  77. :current-page="currentPage"
  78. :page-sizes="[20, 50, 100, 200]"
  79. :page-size="20"
  80. layout="total,sizes, prev, pager, next, jumper"
  81. :total="total"
  82. ></el-pagination>
  83. </div>
  84. <span slot="footer" class="dialog-footer" v-if="creatShow">
  85. <el-button
  86. @click="dialogTableVisible = false"
  87. type="primary"
  88. size="small"
  89. class="normal-btn-width"
  90. >{{ $t("确 定") }}</el-button
  91. >
  92. <!-- <el-button :type="buttonTitle === '确定保存'?'warning':'primary'" @click="onCheck" size="small" class="normal-btn-width">{{buttonTitle}}</el-button>-->
  93. </span>
  94. </el-dialog>
  95. </div>
  96. </template>
  97. <script>
  98. export default {
  99. name: "customerCheck",
  100. props: ["data", "title"],
  101. data() {
  102. return {
  103. dialogTableVisible: false,
  104. list: [],
  105. tablecols: [],
  106. total: 0,
  107. currentPage: 0,
  108. duplicates: false,
  109. creatShow: false,
  110. message: "该客户疑似重复,是否确认创建客户?",
  111. buttonTitle: "确定创建",
  112. param: {
  113. id: 20221208172002,
  114. content: {
  115. sa_customersid: "",
  116. enterprisename: "",
  117. taxno: "",
  118. address: "",
  119. },
  120. },
  121. fields1: [],
  122. fields2: [],
  123. fields3: [],
  124. siteid:JSON.parse(sessionStorage.getItem('active_account')).siteid,
  125. };
  126. },
  127. methods: {
  128. async listData() {
  129. this.param.content.sa_customersid = 0;
  130. this.fields1.forEach((item) => {
  131. this.param.content[item] = this.data[item] || "";
  132. });
  133. this.fields2.forEach((item) => {
  134. this.param.content[item] = this.data[item] || "";
  135. });
  136. this.fields3.forEach((item) => {
  137. this.param.content[item] = this.data[item] || "";
  138. });
  139. const res = await this.$api.requested(this.param);
  140. if (res.code == 0) {
  141. this.tool.showMessage(res);
  142. } else {
  143. if (res.total > 0) {
  144. this.list = res.data;
  145. this.total = res.total;
  146. this.currentPage = res.pageNumber;
  147. this.dialogTableVisible = true;
  148. this.$emit("isDuplicate", "重复");
  149. } else {
  150. if (this.creatShow) {
  151. this.onSubmit();
  152. } else {
  153. this.$message({
  154. message: this.$t("无重复数据"),
  155. type: "success",
  156. });
  157. this.$emit("isDuplicate", "无重复数据");
  158. }
  159. }
  160. }
  161. },
  162. onCheck() {
  163. if (this.buttonTitle === "确定保存") {
  164. this.message = "该客户疑似重复,是否确认更新客户?";
  165. } else {
  166. this.message = "该客户疑似重复,是否确认创建客户?";
  167. }
  168. this.$confirm(this.$t(this.message), this.$t("提示"), {
  169. confirmButtonText: this.$t("确定"),
  170. cancelButtonText: this.$t("取消"),
  171. type: "warning",
  172. })
  173. .then(() => {
  174. this.duplicates = true;
  175. this.onSubmit();
  176. })
  177. .catch(() => {
  178. this.$message({
  179. type: "info",
  180. message: this.$t("已取消"),
  181. });
  182. });
  183. },
  184. async onSubmit() {
  185. if (this.data.contactsinfo.telephone) {
  186. this.data.contactsinfo.phonenumber = this.data.contactsinfo.telephone;
  187. this.data.contactsinfo.telephone = "";
  188. }
  189. const res = await this.$api.requested({
  190. id: 20221216184302,
  191. content: this.data,
  192. });
  193. this.tool.showMessage(res, () => {
  194. if (this.duplicates) {
  195. this.setTag(res.data.sa_customersid, "疑似重复");
  196. } else {
  197. this.$emit("onSuccess");
  198. /* this.setTag(res.data.sa_customersid,'')*/
  199. }
  200. });
  201. },
  202. async setTag(id, data) {
  203. const res = await this.$api.requested({
  204. id: 20220929090901,
  205. content: {
  206. ownertable: "sa_customers",
  207. ownerid: id,
  208. datatag: [data],
  209. },
  210. });
  211. this.dialogTableVisible = false;
  212. this.duplicates = false;
  213. this.$emit("onSuccess");
  214. },
  215. handleSizeChange(val) {
  216. // console.log(`每页 ${val} 条`);
  217. this.param.content.pageSize = val;
  218. this.listData();
  219. },
  220. handleCurrentChange(val) {
  221. // console.log(`当前页: ${val}`);
  222. this.param.content.pageNumber = val;
  223. this.listData();
  224. },
  225. /*查询规则*/
  226. isCheck() {
  227. this.$emit("onCheck");
  228. },
  229. async queryRule() {
  230. const res = await this.$api.requested({
  231. id: "20230410090502",
  232. content: {},
  233. });
  234. this.fields1 = res.data.custcheckrule.fields1;
  235. this.fields2 = res.data.custcheckrule.fields2;
  236. this.fields3 = res.data.custcheckrule.fields3;
  237. this.listData();
  238. },
  239. },
  240. created() {
  241. this.tablecols = this.tool.tabelCol(
  242. this.$route.name
  243. ).duplicatesCustomerTable.tablecols;
  244. },
  245. };
  246. </script>
  247. <style scoped>
  248. </style>