소스 검색

销售端新增根据进粉天数打标签+销售端隐藏删除客户信息表信息

cgp 3 주 전
부모
커밋
84a5d0526d
3개의 변경된 파일661개의 추가작업 그리고 8개의 파일을 삭제
  1. 44 0
      src/api/qw/quickTagTask.js
  2. 0 8
      src/views/qw/companyCustomer/index.vue
  3. 617 0
      src/views/qw/quickTagTask/quickTagTask.vue

+ 44 - 0
src/api/qw/quickTagTask.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 查询任务列表(分页)
+export function listQuickTagTask(query) {
+  return request({
+    url: '/qw/quickTagTask/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询任务详情
+export function getQuickTagTask(id) {
+  return request({
+    url: '/qw/quickTagTask/' + id,
+    method: 'get'
+  })
+}
+
+// 新增任务
+export function addQuickTagTask(data) {
+  return request({
+    url: '/qw/quickTagTask',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改任务
+export function updateQuickTagTask(data) {
+  return request({
+    url: '/qw/quickTagTask',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除任务(支持单个或批量)
+export function delQuickTagTask(ids) {
+  return request({
+    url: '/qw/quickTagTask/' + ids,
+    method: 'delete'
+  })
+}

+ 0 - 8
src/views/qw/companyCustomer/index.vue

@@ -428,14 +428,6 @@
             @click="handleUpdate(scope.row)"
             >修改</el-button
           >
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            v-if="scope.row.myCustomerFlag"
-            @click="handleDelete(scope.row)"
-            >删除</el-button
-          >
           <el-button
             size="mini"
             type="text"

+ 617 - 0
src/views/qw/quickTagTask/quickTagTask.vue

@@ -0,0 +1,617 @@
+<template>
+  <div class="app-container">
+    <!-- 搜索栏 -->
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
+      <el-form-item label="企微公司" prop="corpId">
+        <el-select
+          v-model="queryParams.corpId"
+          placeholder="请选择企微公司"
+          size="small"
+          @change="handleCorpChange"
+        >
+          <el-option
+            v-for="item in companyList"
+            :key="item.dictValue"
+            :label="item.dictLabel"
+            :value="item.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="标签" prop="tagId">
+        <el-select
+          v-model="queryParams.tagId"
+          placeholder="请选择标签(用于搜索)"
+          size="small"
+          clearable
+          filterable
+        >
+          <el-option
+            v-for="tag in tagList"
+            :key="tag.tagId"
+            :label="tag.name"
+            :value="tag.tagId"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <!-- 操作按钮 -->
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+        >删除</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <!-- 表格 -->
+    <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="任务ID" align="center" prop="id" />
+      <el-table-column label="公司主体" align="center">
+        <template slot-scope="scope">
+          {{ getCorpName(scope.row.corpId) }}
+        </template>
+      </el-table-column>
+      <el-table-column label="进粉后触发打标签天数" align="center" prop="executionDays" />
+      <el-table-column label="标签" align="center">
+        <template slot-scope="scope">
+          <div class="tag-list">
+            <el-tag
+              type="success"
+              v-for="tagId in splitTagIds(scope.row.tagId)"
+              :key="tagId"
+              style="margin: 2px;"
+            >
+              {{ getTagName(tagId) }}
+            </el-tag>
+          </div>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 分页组件 -->
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 新增/修改弹窗 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
+        <el-form-item label="企微公司" prop="corpId">
+          <el-select
+            v-model="form.corpId"
+            placeholder="请选择企微公司"
+            style="width: 100%;"
+            @change="handleFormCorpChange"
+          >
+            <el-option
+              v-for="item in companyList"
+              :key="item.dictValue"
+              :label="item.dictLabel"
+              :value="item.dictValue"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="进粉后触发打标签天数" prop="executionDays">
+          <el-input-number
+            v-model="form.executionDays"
+            :min="0"
+            placeholder="请输入进粉后触发打标签天数"
+            style="width: 100%;"
+            controls-position="right"
+          />
+        </el-form-item>
+        <el-form-item label="标签" prop="tagId">
+          <!-- 点击选择多标签 -->
+          <div
+            @click="handleChangeTags"
+            style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; width: 100%; min-height: 35px; border-radius: 4px;"
+          >
+            <div style="min-height: 35px; max-height: 200px; overflow-y: auto; padding: 5px;">
+              <span v-if="!form.tagId || form.tagId.length === 0" style="color: #999; line-height: 35px; padding-left: 10px;">
+                请点击选择标签(可多选)
+              </span>
+              <el-tag
+                type="success"
+                closable
+                :disable-transitions="false"
+                v-for="tagId in splitTagIds(form.tagId)"
+                :key="tagId"
+                @close="handleRemoveTag(tagId)"
+                style="margin: 3px;"
+              >
+                {{ getTagName(tagId) }}
+              </el-tag>
+            </div>
+          </div>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- 标签选择对话框(多选) -->
+    <el-dialog title="选择标签(可多选)" :visible.sync="tagChange.open" width="800px" append-to-body>
+      <div>
+        搜索标签:
+        <el-input
+          v-model="queryTagParams.name"
+          placeholder="请输入标签名称"
+          clearable
+          size="small"
+          style="width: 200px;margin-right: 10px"
+          @keyup.enter.native="handleSearchTags"
+        />
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags">搜索</el-button>
+        <el-button type="primary" icon="el-icon-refresh" size="mini" @click="cancelSearchTags">重置</el-button>
+      </div>
+      <div v-for="item in tagGroupList" :key="item.id">
+        <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
+          <span class="name-background">{{ item.name }}</span>
+        </div>
+        <div class="scroll-wrapper">
+          <div class="tag-container">
+            <a
+              v-for="tagItem in item.tag"
+              class="tag-box"
+              @click="tagSelection(tagItem)"
+              :class="{ 'tag-selected': tagItem.isSelected }"
+            >
+              {{ tagItem.name }}
+            </a>
+          </div>
+        </div>
+      </div>
+      <pagination
+        v-show="tagTotal>0"
+        :total="tagTotal"
+        :page.sync="queryTagParams.pageNum"
+        :limit.sync="queryTagParams.pageSize"
+        @pagination="getPageListTagGroup"
+      />
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="addTagSubmitForm">确 定</el-button>
+        <el-button @click="addTagCancel">重 置</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listQuickTagTask, getQuickTagTask, addQuickTagTask, updateQuickTagTask, delQuickTagTask } from '@/api/qw/quickTagTask'
+import { getMyQwCompanyList } from '@/api/qw/user'
+import { listTag, searchTags } from '@/api/qw/tag'
+import { allListTagGroup } from '@/api/qw/tagGroup'
+
+export default {
+  name: 'QuickTagTask',
+  data() {
+    return {
+      loading: true,
+      ids: [],
+      single: true,
+      multiple: true,
+      showSearch: true,
+      total: 0,
+      tableData: [],
+      title: '',
+      open: false,
+      companyList: [],
+      tagList: [],               // 所有标签(用于下拉搜索和名称映射)
+      tagGroupList: [],          // 标签分组(用于选择对话框)
+      queryTagParams: {
+        pageNum: 1,
+        pageSize: 5,
+        name: null,
+        corpId: null
+      },
+      tagTotal: 0,
+      tagChange: {
+        open: false
+      },
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        corpId: null,
+        executionDays: null,
+        tagId: null       // 搜索条件,单个标签ID
+      },
+      form: {
+        id: null,
+        corpId: null,
+        executionDays: null,
+        tagId: null       // 存储逗号分隔的标签ID字符串
+      },
+      rules: {
+        corpId: [
+          { required: true, message: '请选择企微公司', trigger: 'change' }
+        ],
+        executionDays: [
+          { required: true, message: '执行天数不能为空', trigger: 'blur' }
+        ],
+        tagId: [
+          { required: true, message: '请至少选择一个标签', trigger: 'change' }
+        ]
+      },
+      // 新增:独立存储所有已选中的标签ID(跨页)
+      selectedTagIds: []
+    }
+  },
+  created() {
+    this.loadCompanyList()
+  },
+  methods: {
+    /** 加载公司列表 */
+    loadCompanyList() {
+      getMyQwCompanyList().then(response => {
+        this.companyList = response.data || []
+        if (this.companyList.length > 0) {
+          this.queryParams.corpId = this.companyList[0].dictValue
+          this.loadTagList(this.queryParams.corpId)
+          this.getList()
+        } else {
+          this.$message.warning('未获取到企微公司数据')
+        }
+      })
+    },
+    /** 加载标签列表(用于下拉和名称映射) */
+    loadTagList(corpId) {
+      if (!corpId) return
+      listTag({ corpId: corpId }).then(response => {
+        this.tagList = response.rows || []
+      })
+    },
+    /** 获取公司名称 */
+    getCorpName(corpId) {
+      if (!corpId) return ''
+      const item = this.companyList.find(c => c.dictValue === corpId)
+      return item ? item.dictLabel : corpId
+    },
+    /** 获取标签名称 */
+    getTagName(tagId) {
+      if (!tagId) return ''
+      const tag = this.tagList.find(t => t.tagId === tagId)
+      return tag ? tag.name : tagId
+    },
+    /** 将逗号分隔的字符串转为数组 */
+    splitTagIds(tagIdStr) {
+      if (!tagIdStr) return []
+      return tagIdStr.split(',').filter(id => id.trim() !== '')
+    },
+    /** 查询列表 */
+    getList() {
+      this.loading = true
+      listQuickTagTask(this.queryParams).then(response => {
+        this.tableData = response.rows
+        this.total = response.total
+        this.loading = false
+      })
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false
+      this.reset()
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        corpId: this.queryParams.corpId,
+        executionDays: null,
+        tagId: null
+      }
+      if (this.resetForm) {
+        this.resetForm('form')
+      } else {
+        this.$refs.form && this.$refs.form.resetFields()
+      }
+    },
+    /** 搜索按钮 */
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    /** 重置按钮 */
+    resetQuery() {
+      if (this.resetForm) {
+        this.resetForm('queryForm')
+      } else {
+        this.$refs.queryForm && this.$refs.queryForm.resetFields()
+      }
+      if (this.companyList.length > 0) {
+        this.queryParams.corpId = this.companyList[0].dictValue
+        this.loadTagList(this.queryParams.corpId)
+      }
+      this.queryParams.executionDays = null
+      this.queryParams.tagId = null
+      this.handleQuery()
+    },
+    /** 公司切换(搜索栏) */
+    handleCorpChange(val) {
+      this.loadTagList(val)
+      this.queryParams.tagId = null
+      this.handleQuery()
+    },
+    /** 公司切换(表单内) */
+    handleFormCorpChange(val) {
+      this.loadTagList(val)
+      this.form.tagId = null
+    },
+    // 多选框选中
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length !== 1
+      this.multiple = !selection.length
+    },
+    /** 新增 */
+    handleAdd() {
+      this.reset()
+      if (this.queryParams.corpId) {
+        this.form.corpId = this.queryParams.corpId
+        this.loadTagList(this.queryParams.corpId)
+      }
+      this.open = true
+      this.title = '添加自动打标签任务'
+    },
+    /** 修改 */
+    handleUpdate(row) {
+      this.reset()
+      const id = row.id || this.ids[0]
+      getQuickTagTask(id).then(response => {
+        const data = response.data
+        this.form = {
+          id: data.id,
+          corpId: data.corpId,
+          executionDays: data.executionDays,
+          tagId: data.tagId   // 直接赋值逗号分隔字符串
+        }
+        if (data.corpId) {
+          this.loadTagList(data.corpId)
+        }
+        this.open = true
+        this.title = '修改自动打标签任务'
+      })
+    },
+    /** 提交 */
+    submitForm() {
+      this.$refs['form'].validate(valid => {
+        if (valid) {
+          // 检查是否至少选了一个标签
+          if (!this.form.tagId || this.splitTagIds(this.form.tagId).length === 0) {
+            this.$message.warning('请至少选择一个标签')
+            return
+          }
+          if (this.form.id != null) {
+            updateQuickTagTask(this.form).then(() => {
+              this.$message.success('修改成功')
+              this.open = false
+              this.getList()
+            })
+          } else {
+            addQuickTagTask(this.form).then(() => {
+              this.$message.success('新增成功')
+              this.open = false
+              this.getList()
+            })
+          }
+        }
+      })
+    },
+    /** 删除 */
+    handleDelete(row) {
+      const ids = row.id ? [row.id] : this.ids
+      if (ids.length === 0) {
+        this.$message.warning('请选择要删除的数据')
+        return
+      }
+      this.$confirm('是否确认删除选中的数据?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return delQuickTagTask(ids.join(','))
+      }).then(() => {
+        this.getList()
+        this.$message.success('删除成功')
+      }).catch(() => {})
+    },
+
+    // ========== 标签选择相关方法(多选,修复跨页选中丢失) ==========
+    /** 打开标签选择对话框 */
+    handleChangeTags() {
+      // 从 form.tagId 初始化选中列表
+      this.selectedTagIds = this.splitTagIds(this.form.tagId)
+      this.queryTagParams.corpId = this.form.corpId || this.queryParams.corpId
+      this.getPageListTagGroup()
+      this.tagChange.open = true
+    },
+
+    /** 获取标签分组列表(分页) */
+    getPageListTagGroup() {
+      allListTagGroup(this.queryTagParams).then(response => {
+        this.tagGroupList = response.rows || []
+        this.tagTotal = response.total || 0
+        // 根据 selectedTagIds 标记当前页的选中状态
+        this.tagGroupList.forEach(group => {
+          group.tag.forEach(tag => {
+            tag.isSelected = this.selectedTagIds.includes(tag.tagId)
+          })
+        })
+      })
+    },
+
+    /** 搜索标签 */
+    handleSearchTags() {
+      if (!this.queryTagParams.name) {
+        return this.$message.error('请输入要搜索的标签名称')
+      }
+      this.queryTagParams.corpId = this.form.corpId || this.queryParams.corpId
+      searchTags(this.queryTagParams).then(response => {
+        this.tagGroupList = response.rows || []
+        // 根据 selectedTagIds 标记选中状态
+        this.tagGroupList.forEach(group => {
+          group.tag.forEach(tag => {
+            tag.isSelected = this.selectedTagIds.includes(tag.tagId)
+          })
+        })
+      })
+    },
+
+    /** 重置搜索 */
+    cancelSearchTags() {
+      this.queryTagParams.name = null
+      this.queryTagParams.pageNum = 1
+      this.getPageListTagGroup()
+    },
+
+    /** 标签点击选择(多选,切换选中状态) */
+    tagSelection(row) {
+      row.isSelected = !row.isSelected
+      // 同步更新 selectedTagIds
+      const tagId = row.tagId
+      if (row.isSelected) {
+        if (!this.selectedTagIds.includes(tagId)) {
+          this.selectedTagIds.push(tagId)
+        }
+      } else {
+        const index = this.selectedTagIds.indexOf(tagId)
+        if (index !== -1) {
+          this.selectedTagIds.splice(index, 1)
+        }
+      }
+      this.$forceUpdate()
+    },
+
+    /** 确认选择标签(使用 selectedTagIds 提交) */
+    addTagSubmitForm() {
+      if (this.selectedTagIds.length === 0) {
+        this.$message.warning('请至少选择一个标签')
+        return
+      }
+      this.form.tagId = this.selectedTagIds.join(',')
+      this.tagChange.open = false
+    },
+
+    /** 重置选择(清空所有选中) */
+    addTagCancel() {
+      this.tagChange.open = false
+      // 清空选中状态(不改变已选?但按业务“重置”应清空所有选中)
+      this.selectedTagIds = []
+      // 同时清除当前页的选中样式
+      this.tagGroupList.forEach(group => {
+        group.tag.forEach(tag => {
+          tag.isSelected = false
+        })
+      })
+    },
+
+    /** 删除已选中的某个标签(点击表单标签的关闭按钮) */
+    handleRemoveTag(tagId) {
+      const ids = this.splitTagIds(this.form.tagId)
+      const index = ids.indexOf(tagId)
+      if (index !== -1) {
+        ids.splice(index, 1)
+        this.form.tagId = ids.join(',')
+        // 同时从 selectedTagIds 中移除(如果对话框打开,需同步)
+        const idx = this.selectedTagIds.indexOf(tagId)
+        if (idx !== -1) {
+          this.selectedTagIds.splice(idx, 1)
+        }
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+/* 样式与参考页面一致 */
+.tag-container {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px;
+}
+
+.name-background {
+  display: inline-block;
+  background-color: #abece6;
+  padding: 4px 8px;
+  border-radius: 4px;
+}
+
+.tag-box {
+  padding: 8px 12px;
+  border: 1px solid #989797;
+  border-radius: 4px;
+  cursor: pointer;
+  display: inline-block;
+}
+
+.tag-selected {
+  background-color: #00bc98;
+  color: #fff;
+  border-color: #00bc98;
+}
+
+.scroll-wrapper {
+  max-height: 130px;
+  overflow-y: auto;
+  padding-right: 5px;
+}
+
+.scroll-wrapper::-webkit-scrollbar {
+  width: 6px;
+}
+
+.scroll-wrapper::-webkit-scrollbar-thumb {
+  background: rgba(0, 0, 0, 0.2);
+  border-radius: 3px;
+}
+
+.tag-list {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 4px;
+}
+</style>