competitorCheck.vue 5.8 KB

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