projectChangeCheck.vue 9.4 KB

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