| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <div>
- <el-button size="small" type="primary" @click="isCheck" class="inline-16 normal-btn-width">查 重</el-button>
- <el-dialog title="重复竞争对手" :visible.sync="dialogTableVisible" append-to-body width="1000px">
- <div slot="title" class="dialog-title">
- <span class="title-text">重复竞争对手</span>
- <p v-if="buttonTitle === '确定保存'" style="font-size: 14px;color: red">已存在重复竞争对手,是否确认继续保存</p>
- <p v-else style="font-size: 14px;color: red">已存在重复竞争对手,是否确认继续创建</p>
- </div>
- <tableLayout :layout="tablecols" :data="list" :opwidth="200" height="calc(100vh - 550px)" :width="true" :custom="true">
- <template v-slot:customcol="scope">
- <p >{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
- </template>
- </tableLayout>
- <div class="container normal-panel" style="text-align:right">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[20, 50, 100, 200]"
- :page-size="20"
- :total="total">
- </el-pagination>
- </div>
- <span slot="footer" class="dialog-footer" v-if="creatShow">
- <el-button @click="dialogTableVisible = false" size="small" class="normal-btn-width">取 消</el-button>
- <el-button :type="buttonTitle === '确定保存'?'warning':'primary'" @click="onCheck" size="small" class="normal-btn-width">{{buttonTitle}}</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import tableLayout from '@/components/table/index5'
- export default {
- components:{tableLayout},
- name: "customerCheck",
- props:["data"],
- data(){
- return {
- dialogTableVisible:false,
- list:[],
- tablecols:[],
- total:0,
- currentPage:0,
- duplicates:false,
- creatShow:false,
- message:'该竞争对手疑似重复,是否确认创建竞争对手?',
- buttonTitle:'确定创建',
- param:{
- "id": 20230324132602,
- "content": {
- "sa_competitorid":"",
- "enterprisename":"",
- },
- },
- fields1:[],
- fields2:[],
- fields3:[],
- }
- },
- methods:{
- isCheck(){
- this.$emit('onCheck')
- },
- async listData(){
- this.param.content.sa_competitorid = this.data.sa_competitorid || 0
- this.param.content.enterprisename = this.data.enterprisename
- const res = await this.$api.requested(this.param)
- if (res.total > 0){
- this.list = res.data
- this.total = res.total
- this.currentPage = res.pageNumber
- this.dialogTableVisible = true
- }else {
- if (this.creatShow){
- this.onSubmit()
- }else {
- this.$message({
- message: '无重复数据',
- type: 'success'
- });
- }
- }
- },
- onCheck(){
- if (this.buttonTitle === '确定保存'){
- this.message = '该竞争对手疑似重复,是否确认更新竞争对手?'
- }else {
- this.message = '该竞争对手疑似重复,是否确认创建竞争对手?'
- }
- this.$confirm(this.message, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.duplicates = true
- this.onSubmit()
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- });
- });
- },
- async onSubmit(){
- this.data.sys_enterpriseid = 0
- const res = await this.$api.requested({
- "id": 20221018164102,
- "content": this.data
- })
- this.tool.showMessage(res,()=>{
- if (this.duplicates){
- if (this.buttonTitle === '确定保存'){
- this.tagData(res.data.sa_competitorid)
- }else {
- let data = ['疑似重复']
- this.setTag(res.data.sa_competitorid,data)
- }
- }else {
- this.$emit('onSuccess')
- /* this.setTag(res.data.sa_customersid,'')*/
- }
- })
- },
- async setTag(id,data){
- const res = await this.$api.requested({
- "id": 20220929090901,
- "content": {
- "ownertable":"sa_competitor",
- "ownerid":id,
- "datatag":data
- }
- })
- this.dialogTableVisible = false
- this.duplicates = false
- this.$emit('onSuccess')
- },
- handleSizeChange(val) {
- // console.log(`每页 ${val} 条`);
- this.param.content.pageSize = val
- this.listData()
- },
- handleCurrentChange(val) {
- // console.log(`当前页: ${val}`);
- this.param.content.pageNumber = val
- this.listData()
- },
- // 获取标签数据
- async tagData(id){
- const res = await this.$api.requested({
- content: {
- ownertable: "sa_competitor",
- ownerid: this.$route.query.id
- },
- id: 20220929085401
- })
- var resTagData = []
- resTagData = res.data.datatag
- if (this.duplicates){
- let flag = 0
- for (var i=0;i<res.data.datatag.length;i++){
- if (res.data.datatag[i] === '疑似重复'){
- flag = 1
- break
- }
- }
- if (flag === 1){
- this.setTag(id,resTagData)
- }else {
- resTagData.push('疑似重复')
- this.setTag(id,resTagData)
- }
- }else {
- for (var k=0;k<res.data.datatag.length;k++){
- if (res.data.datatag[k] === '疑似重复'){
- resTagData.splice(k)
- break
- }
- }
- this.setTag(id,resTagData)
- }
- },
- },
- created() {
- this.tablecols = this.tool.tabelCol(this.$route.name).duplicatesCompetitorTable.tablecols
- }
- }
- </script>
- <style scoped>
- </style>
|