competitorCheck.vue 6.6 KB

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