index.vue 8.29 KB
<!-- 标签课程 -->
<template>
  <d2-container class="customer-tags">
    <div class="header" slot="header">
      <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :label-width="'100px'"
        :form-data="showFormData">
      </d2-search>
      <div class="up-btns">
        <el-button size="small" type="primary" @click="handleSearch">
          查询
        </el-button>
        <el-button size="small" @click="handleReset"> 重置 </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <el-button size="small" type="primary" @click="addLabelCourse">
          新增课程标签
        </el-button>
      </d2-table-header>
      <d2-table ref="table" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams"
        :before-search-fn="beforeSearchFn">
        <template slot="tagName" scope="scope">
          <!-- <div v-for="(item, index) in scope.scope.tagList.split(',')" :key="index">
            {{ item }}
          </div> -->
          <el-tooltip class="item" effect="dark" placement="top">
            <div slot="content" class="tag-name">
              <div v-for="(item, index) in scope.scope.tagList.split(',')" :key="index">{{ item }}</div>
            </div>
            <div>
              {{ scope.scope.tagList.split(',')[0] + (scope.scope.tagList.split(',').length == 1 ? '' : '...') + ' ' +
                `(${scope.scope.tagList.split(',').length}条)` }}
            </div>
          </el-tooltip>
        </template>
        <template slot="courseList" scope="scope">
          <el-tooltip v-for="(item, index) in scope.scope.courseList.split(',')" :key="index" class="item" effect="dark"
            :content="item" placement="top">
            <div class="one-line-ellipsis">
              {{ item }}
            </div>
          </el-tooltip>

        </template>
        <auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" />
      </d2-table>
    </div>
    <labelCourseDialog :recordInfo="recordInfo" v-if="dialogVisible" :dialogVisible.sync="dialogVisible"
      @confirmDialogFn="confirmDialogFn">
    </labelCourseDialog>
  </d2-container>
</template>

<script type="text/ecmascript-6">
import labelCourseDialog from "./labelCourseDialog"
import { Util, deepClone } from "@/common/util"
import {
  findStaffTagCourseRelationPage,
  deletecourserelation,
  updatecourserelation,
  savecourserelation
} from "@api/contentManager"
import noDataImg from "@/assets/empty.png"
import dayjs from "dayjs"
export default {
  name: "labelCourse",
  components: {
    labelCourseDialog
  },
  data() {
    return {
      recordInfo: null,
      dialogVisible: false,
      noDataImg,
      classifyVisible: false,
      searchForm: {
        courseName: "",
        tagName: ""
        // bussinessScene: "",
        // merchantId: "",
        // scriptMatching: "",
        // receptionist: "",
        // solutionBrowsing: "",
        // searchdate: [new Date(), new Date()]
      },
      searchFormSearch: {},
      currentItem: {},
      showFormData: [
        {
          label: "标签名",
          name: "tagName",
          type: "input",
          isClear: true,
          maxlength: 50
        },
        {
          label: "课程名称",
          name: "courseName",
          type: "input",
          isClear: true,
          maxlength: 50
        },
      ],
      getListApi: findStaffTagCourseRelationPage,
      // 表格参数
      tableParams: {
        listName: "list",
        tableOption: {
          width: "100"
        },
        tableColumns: [
          {
            label: "标签",
            prop: "tagList",
            addHtml: "tagName",
          },
          {
            label: "课程列表",
            // minWidth: 144,
            addHtml: "courseList"
          },
          // {
          //   label: "销售姓名",
          //   prop: "receptionist"
          // },
          // {
          //   label: "客户姓名",
          //   prop: "ownerName",
          //   minWidth: 140
          // },
          // {
          //   label: "品牌车型",
          //   prop: "brandModel",
          //   minWidth: 140
          // },
          // {
          //   label: "接待场景",
          //   prop: "receptionSceneName"
          // },
          // {
          //   label: "话术匹配",
          //   formatter: (cellValue) => {
          //     return cellValue.scriptMatchingCount || 0
          //   }
          // },
          // {
          //   label: "方案浏览",
          //   formatter: (cellValue) => {
          //     return cellValue.solutionBrowsingCount || 0
          //   }
          // },
          // {
          //   label: "客户标签",
          //   minWidth: 270,
          //   addHtml: "customerTagName"
          // },
          {
            label: "创建时间",
            formatter: (cellValue) => {
              return cellValue.createdDate
                ? Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss")
                : "-"
            },
            width: 140
          },
          {
            label: "最后更新时间",
            formatter: (cellValue) => {
              return cellValue.updatedDate
                ? Util.dateFormate(cellValue.updatedDate, "YYYY-MM-DD HH:mm:ss")
                : "-"
            },
            width: 140
          }
        ]
      }
    }
  },
  created() { },
  mounted() {
    // this.getCustomerFileStatic()
  },
  methods: {
    beforeSearchFn(type = 1) {
      return new Promise((resolve, reject) => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },
    handleSearch() {
      this.page = this.$options.data.call(this).page
      this.$refs.table.refreshTable(true, true)
      // this.getCustomerFileStatic()
    },
    handleReset() {
      this.searchForm = this.$options.data.call(this).searchForm
      this.handleSearch()
    },
    addLabelCourse() {
      this.recordInfo = null
      this.dialogVisible = true
    },
    customerTagName(list) {
      let tag = []
      list.map((e) => {
        tag.push(e.labelName)
      })
      return tag.join("|")
    },
    handleEdit(row) {
      console.log(row)
      this.recordInfo = row
      this.dialogVisible = true
    },
    confirmDialogFn(e) {
      this.handleSearch()
    },
    // 删除
    handleDelete(row) {
      this.$confirm('是否确认删除该课程?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error'
      }).then(() => {
        deletecourserelation({ id: row.id }).then(res => {
          this.notice.okTips()
          this.$refs.table.refreshTable()
        })
      }).catch(err => {
        console.log(err)
      })
    },
    // jumpDetail(row) {
    //   this.$router.push({
    //     name: "customerFileDetails",
    //     query: {
    //       id: row.id,
    //       receptionSceneName: row.receptionSceneName,
    //       receptionScene: row.receptionScene,
    //       scene: row.bussinessScene
    //     }
    //   })
    // }
  }
}
</script>

<style scoped lang="scss">
.emptyBg {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 120px 0;

  .noDataImg {
    width: 64px;
    height: 40px;
  }
}

.error-input {
  ::v-deep.el-input__inner {
    border-color: red;
  }
}

.tag-item {
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;

  .tag {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .more-info {
    white-space: nowrap;
    color: #2a58ad;
    cursor: pointer;
    margin-left: 2px;
  }
}

::v-deep.tags-popover {
  max-width: 50vw;
}

.static-box {
  display: flex;
  gap: 0 16px;
  margin-bottom: 12px;

  .static-item {
    flex: 1;
    flex-shrink: 0;
    height: 82px;
    background: #f8faff;
    border-radius: 5px;
    box-sizing: border-box;
    padding: 16px 20px;

    .static-title {
      font-size: 14px;
      color: #333333;
      line-height: 20px;
      margin-bottom: 4px;
    }

    .static-value {
      display: flex;
      font-weight: 700;
      font-size: 24px;
      line-height: 30px;
      align-items: baseline;

      ::v-deep.static-unit {
        font-weight: 600;
        font-size: 14px;
        margin: 0 2px;
      }
    }
  }
}

.tag-name {
  max-height: 300px;
  overflow-y: scroll;
}
</style>