Commit fccbf2cf by 李伟康

commit 客户标签

1 parent f4362e08
...@@ -3,200 +3,216 @@ import request from "./request" ...@@ -3,200 +3,216 @@ import request from "./request"
const path = "dj.api." const path = "dj.api."
// 内容管理列表查询条件可见门店列表 // 内容管理列表查询条件可见门店列表
export function getMerchantList(data) { export function getMerchantList (data) {
data.method = `dj.smartcarlife.api.shopMerchant.list` data.method = `dj.smartcarlife.api.shopMerchant.list`
return request(data) return request(data)
} }
// 内容管理列表查询 // 内容管理列表查询
export function getContenttList(data) { export function getContenttList (data) {
data.method = `${path}material.record.page` data.method = `${path}material.record.page`
return request(data) return request(data)
} }
// 内容管理详情 // 内容管理详情
export function getContentDetail(data) { export function getContentDetail (data) {
data.method = `${path}material.record.detail` data.method = `${path}material.record.detail`
return request(data) return request(data)
} }
// 批量启停用内容 // 批量启停用内容
export function batchOperaterContent(data) { export function batchOperaterContent (data) {
data.method = `${path}material.record.batch.operate` data.method = `${path}material.record.batch.operate`
return request(data) return request(data)
} }
// 删除内容 // 删除内容
export function delContent(data) { export function delContent (data) {
data.method = `${path}material.record.delete` data.method = `${path}material.record.delete`
return request(data) return request(data)
} }
// 统计列表 // 统计列表
export function getStatisticsList(data) { export function getStatisticsList (data) {
data.method = `dj.api.customer.dynamic.record.page` data.method = `dj.api.customer.dynamic.record.page`
return request(data) return request(data)
} }
// 导出统计列表 // 导出统计列表
export function exportStatisticsList(data) { export function exportStatisticsList (data) {
data.method = `dj.api.customer.dynamic.record.page.export` data.method = `dj.api.customer.dynamic.record.page.export`
return request(data) return request(data)
} }
// 新增内容 // 新增内容
export function addContent(data) { export function addContent (data) {
data.method = `${path}material.record.add` data.method = `${path}material.record.add`
return request(data, "post") return request(data, "post")
} }
// 编辑内容 // 编辑内容
export function updateContent(data) { export function updateContent (data) {
data.method = `${path}material.record.update` data.method = `${path}material.record.update`
return request(data, "post") return request(data, "post")
} }
// 获取会员权益/升级和积分商城 门店 // 获取会员权益/升级和积分商城 门店
export function getAllMerchantList(data) { export function getAllMerchantList (data) {
data.method = `dj.api.merchant.page` data.method = `dj.api.merchant.page`
return request(data, "POST") return request(data, "POST")
} }
// 获取精品升级/次新车转化/售后众筹 门店 // 获取精品升级/次新车转化/售后众筹 门店
export function getMerchantListByScene(data) { export function getMerchantListByScene (data) {
data.method = `dj.api.scenemerchantref.listShop4sByRef.page` data.method = `dj.api.scenemerchantref.listShop4sByRef.page`
return request(data) return request(data)
} }
// 获取精品升级/次新车转化/售后众筹 门店 // 获取精品升级/次新车转化/售后众筹 门店
export function getListShop4sByRef(data) { export function getListShop4sByRef (data) {
data.method = `dj.api.scenemerchantref.listShop4sByRef` data.method = `dj.api.scenemerchantref.listShop4sByRef`
return request(data) return request(data)
} }
// 获取品牌列表 // 获取品牌列表
export function getBrandList(data) { export function getBrandList (data) {
data.method = `dj.api.smartcarlife.common.car.brand.page` data.method = `dj.api.smartcarlife.common.car.brand.page`
return request(data) return request(data)
} }
// 分页查询标签员工 // 分页查询标签员工
export function getListLabelStaffPage(data) { export function getListLabelStaffPage (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.listLabelStaffPage` data.method = `dj.api.smartcarlife.contentManagerTask.listLabelStaffPage`
return request(data) return request(data)
} }
// 员工群发-分页查询列表 // 员工群发-分页查询列表
export function contentManagerTaskPage(data) { export function contentManagerTaskPage (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.page` data.method = `dj.api.smartcarlife.contentManagerTask.page`
return request(data, "POST") return request(data, "POST")
} }
// 员工群发-删除记录 // 员工群发-删除记录
export function deleteTaskById(data) { export function deleteTaskById (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.deleteById` data.method = `dj.api.smartcarlife.contentManagerTask.deleteById`
return request(data, "POST") return request(data, "POST")
} }
// 员工群发-分页查询内容管理统计信息 // 员工群发-分页查询内容管理统计信息
export function getStatisticPage(data) { export function getStatisticPage (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.statistic.page` data.method = `dj.api.smartcarlife.contentManagerTask.statistic.page`
return request(data, "POST") return request(data, "POST")
} }
// 员工群发-添加/修改记录 // 员工群发-添加/修改记录
export function insertOrUpdate(data) { export function insertOrUpdate (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.insertOrUpdate` data.method = `dj.api.smartcarlife.contentManagerTask.insertOrUpdate`
return request(data, "POST") return request(data, "POST")
} }
// 根据ID查询详细信息 // 根据ID查询详细信息
export function contentManagerTaskById(data) { export function contentManagerTaskById (data) {
data.method = `dj.api.smartcarlife.contentManagerTask.getById` data.method = `dj.api.smartcarlife.contentManagerTask.getById`
return request(data, "POST") return request(data, "POST")
} }
// 获取接待场景 // 获取接待场景
export function receptionSceneList(data) { export function receptionSceneList (data) {
data.method = "dj.api.material.reception.scene.list" data.method = "dj.api.material.reception.scene.list"
return request(data, "POST") return request(data, "POST")
} }
// 获取客户标签树 // 获取客户标签树
export function getLabelList(data) { export function getLabelList (data) {
data.method = "dj.api.material.customer.label.list" data.method = "dj.api.material.customer.label.list"
return request(data, "POST") return request(data, "POST")
} }
// 单一商品 // 单一商品
export function listAllInWithPage(data) { export function listAllInWithPage (data) {
data.method = "dj.api.smartcarlife.upgradeGoods.listAllInWithPage" data.method = "dj.api.smartcarlife.upgradeGoods.listAllInWithPage"
return request(data, "POST") return request(data, "POST")
} }
// 套餐商品 // 套餐商品
export function allInPage(data) { export function allInPage (data) {
data.method = "dj.api.smartcarlife.merchantPackageGoodsInfo.allInPage" data.method = "dj.api.smartcarlife.merchantPackageGoodsInfo.allInPage"
return request(data, "POST") return request(data, "POST")
} }
// 获取产品词条列表 // 获取产品词条列表
export function productTextPage(data) { export function productTextPage (data) {
data.method = "dj.api.material.product.text.page" data.method = "dj.api.material.product.text.page"
return request(data, "POST") return request(data, "POST")
} }
// 分页获取产品词条列表 // 分页获取产品词条列表
export function productPage(data) { export function productPage (data) {
data.method = `dj.api.material.product.text.page` data.method = `dj.api.material.product.text.page`
return request(data, "POST") return request(data, "POST")
} }
// 获取产品词条详情 // 获取产品词条详情
export function productDetail(data) { export function productDetail (data) {
data.method = `dj.api.material.product.text.detail` data.method = `dj.api.material.product.text.detail`
return request(data, "POST") return request(data, "POST")
} }
// 删除产品词条 // 删除产品词条
export function productDelete(data) { export function productDelete (data) {
data.method = `dj.api.material.product.text.delete` data.method = `dj.api.material.product.text.delete`
return request(data, "POST") return request(data, "POST")
} }
// 保存产品词条 // 保存产品词条
export function productSave(data) { export function productSave (data) {
data.method = `dj.api.material.product.text.save` data.method = `dj.api.material.product.text.save`
return request(data, "POST") return request(data, "POST")
} }
// 更新产品词条 // 更新产品词条
export function productUpdate(data) { export function productUpdate (data) {
data.method = `dj.api.material.product.text.update` data.method = `dj.api.material.product.text.update`
return request(data, "POST") return request(data, "POST")
} }
// 查询接待素材商户配置 // 查询接待素材商户配置
export function materialPage(data) { export function materialPage (data) {
data.method = `dj.api.smartcarlife.recepiton.material.page` data.method = `dj.api.smartcarlife.recepiton.material.page`
return request(data, "post", [], "", "/rop-dj-car-boutique/router") return request(data, "post", [], "", "/rop-dj-car-boutique/router")
} }
// 查询门店接待素材详情 // 查询门店接待素材详情
export function materialDetail(data) { export function materialDetail (data) {
data.method = `dj.api.smartcarlife.recepiton.material.merchant.detail` data.method = `dj.api.smartcarlife.recepiton.material.merchant.detail`
return request(data, "post", [], "", "/rop-dj-car-boutique/router") return request(data, "post", [], "", "/rop-dj-car-boutique/router")
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function recepitonUpdate(data) { export function recepitonUpdate (data) {
data.method = `dj.api.smartcarlife.recepiton.material.merchant.saveOrUpdate` data.method = `dj.api.smartcarlife.recepiton.material.merchant.saveOrUpdate`
return request(data, "post", [], "", "/rop-dj-car-boutique/router") return request(data, "post", [], "", "/rop-dj-car-boutique/router")
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function findDictData(data) { export function findDictData (data) {
data.method = `merchants.api.menu.findDictData` data.method = `merchants.api.menu.findDictData`
return request(data, "post") return request(data, "post")
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function deleteDictData(data) { export function deleteDictData (data) {
data.method = `merchants.api.menu.deleteDictData` data.method = `merchants.api.menu.deleteDictData`
return request(data, "post") return request(data, "post")
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function updateDictData(data) { export function updateDictData (data) {
data.method = `merchants.api.menu.updateDictData` data.method = `merchants.api.menu.updateDictData`
return request(data, "post") return request(data, "post")
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function saveDictData(data) { export function saveDictData (data) {
data.method = `merchants.api.menu.saveDictData` data.method = `merchants.api.menu.saveDictData`
return request(data, "post") return request(data, "post")
} }
/**客户标签列表 */
export function getCustomerLabelPage (data) {
data.method = `dj.api.material.customer.label.page`
return request(data, "post")
}
/**新增客户标签 */
export function addCustomerLabel (data) {
data.method = `dj.api.material.customer.label.add`
return request(data, "post")
}
/**修改客户标签 */
export function updateCustomerLabel (data) {
data.method = `dj.api.material.customer.label.update`
return request(data, "post")
}
\ No newline at end of file \ No newline at end of file
<!-- 表格+分页 --> <!-- 表格+分页 -->
<template> <template>
<div class="d2-table"> <div class="d2-table">
<el-table :ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'" <el-table
:data="getListApi ? data : tableData" :ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'"
:row-key="tableParams.mutiSelectUniqueKey || ''" :data="getListApi ? data : tableData"
v-loading="loading" :row-key="tableParams.mutiSelectUniqueKey || ''"
:border="border" v-loading="loading"
:highlight-current-row="true" :border="border"
@sort-change="sortChange" :highlight-current-row="true"
@selection-change="handleSelect" @sort-change="sortChange"
:tree-props="{ children: 'upgradeGoodsList' }" @selection-change="handleSelect"
:span-method="arraySpanMethod" :tree-props="{ children: 'upgradeGoodsList' }"
v-bind="$attrs"> :span-method="arraySpanMethod"
<el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" v-bind="$attrs"
type="selection" >
align="center" <el-table-column
:selectable="selectableFn" v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName"
width="55" /> type="selection"
<el-table-column v-if="tableParams.singleSelectUniqueKey" align="center"
align="center" :selectable="selectableFn"
width="55"> width="55"
/>
<el-table-column
v-if="tableParams.singleSelectUniqueKey"
align="center"
width="55"
>
<template slot-scope="scope"> <template slot-scope="scope">
<slot name="single-button" <slot
:scope="scope.row" /> name="single-button"
:scope="scope.row"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="hasNum" <el-table-column
align="center" v-if="hasNum"
width="60px" align="center"
label="序号" width="60px"
type="index" label="序号"
:index=" type="index"
:index="
(index) => (index) =>
index + index +
((pagination.currentPage ((pagination.currentPage
...@@ -39,32 +48,39 @@ ...@@ -39,32 +48,39 @@
1) * 1) *
(pagination.pageSize ? pagination.pageSize : page.pageSize) + (pagination.pageSize ? pagination.pageSize : page.pageSize) +
1 1
" /> "
<el-table-column v-for="(item, index) in tableParams.tableColumns" />
:key="index" <el-table-column
:label="item.label" v-for="(item, index) in tableParams.tableColumns"
:prop="item.prop" :key="index"
:width="item.width" :label="item.label"
:min-width="item.minWidth" :prop="item.prop"
:align="item.align || 'center'" :width="item.width"
:sortable="item.sortable" :min-width="item.minWidth"
:render-header="item.renderHeader" :align="item.align || 'center'"
:show-overflow-tooltip="item.showOverFlow"> :sortable="item.sortable"
:render-header="item.renderHeader"
:show-overflow-tooltip="item.showOverFlow"
>
<template slot="header"> <template slot="header">
<span>{{ item.label }}</span> <span>{{ item.label }}</span>
<table-head-search v-if="item.optionConfig" <table-head-search
:search-form="headSearchForm" v-if="item.optionConfig"
:option-config="item.optionConfig" :search-form="headSearchForm"
:base-data="baseData" :option-config="item.optionConfig"
@handleTableHeadChange="handleTableHeadChange" /> :base-data="baseData"
@handleTableHeadChange="handleTableHeadChange"
/>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
<slot v-if="item.addHtml" <slot
:name="item.addHtml" v-if="item.addHtml"
:scope="scope.row" :name="item.addHtml"
:index="scope.$index" :scope="scope.row"
:prop="item.prop" :index="scope.$index"
:width="item.width" /> :prop="item.prop"
:width="item.width"
/>
<template v-else-if="item.type == 'ownSerialNum'"> <template v-else-if="item.type == 'ownSerialNum'">
<span>{{ <span>{{
scope.row[item.prop] >= 0 scope.row[item.prop] >= 0
...@@ -81,16 +97,22 @@ ...@@ -81,16 +97,22 @@
}}</span> }}</span>
</template> </template>
<template v-else-if="item.tagLabel"> <template v-else-if="item.tagLabel">
<el-tag v-if="!item.tagName" <el-tag
:type="tableParams.tag.type[scope.row[item.prop]]" v-if="!item.tagName"
v-text="tableParams.tag.label[scope.row[item.prop]]" /> :type="tableParams.tag.type[scope.row[item.prop]]"
<el-tag v-else v-text="tableParams.tag.label[scope.row[item.prop]]"
:type="tableParams[item.tagName].type[scope.row[item.prop]]" />
v-text="tableParams[item.tagName].label[scope.row[item.prop]]" /> <el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
/>
</template> </template>
<template v-else-if="item.formatter"> <template v-else-if="item.formatter">
<span v-if="item.html" <span
v-html="item.formatter(scope.row)" /> v-if="item.html"
v-html="item.formatter(scope.row)"
/>
<template v-if="!item.html"> <template v-if="!item.html">
<span :class="item.className ? item.className(scope.row) : ''" /> <span :class="item.className ? item.className(scope.row) : ''" />
<span v-text="item.formatter(scope.row)" /> <span v-text="item.formatter(scope.row)" />
...@@ -122,38 +144,50 @@ ...@@ -122,38 +144,50 @@
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="tableParams.tableOption" <el-table-column
label="操作" v-if="tableParams.tableOption"
fixed="right" label="操作"
:align="tableParams.tableOption.align || 'center'" fixed="right"
:width="tableParams.tableOption.width || 'auto'"> :align="tableParams.tableOption.align || 'center'"
:width="tableParams.tableOption.width || 'auto'"
>
<template slot-scope="scope"> <template slot-scope="scope">
<slot name="auth-button" <slot
:scope="scope.row" name="auth-button"
:index="scope.$index" /> :scope="scope.row"
<slot name="auth-button-other" :index="scope.$index"
:scope="scope.row" />
:index="scope.$index" /> <slot
name="auth-button-other"
:scope="scope.row"
:index="scope.$index"
/>
</template> </template>
</el-table-column> </el-table-column>
<div slot="empty" <div
class="emptyBg"> slot="empty"
<img class="noDataImg" class="emptyBg"
:src="noDataImg" >
v-if="noDataImg" /> <img
class="noDataImg"
:src="noDataImg"
v-if="noDataImg"
/>
{{ noDataText }} {{ noDataText }}
</div> </div>
</el-table> </el-table>
<el-pagination v-if="hasPage" <el-pagination
background v-if="hasPage"
@size-change="handleSizeChange" background
@current-change="handleCurrentChange" @size-change="handleSizeChange"
:current-page="page.currentPage" @current-change="handleCurrentChange"
:page-sizes="[10, 20, 30, 40]" :current-page="page.currentPage"
:page-size="page.pageSize" :page-sizes="[10, 20, 30, 40]"
:total="getListApi ? total : tableTotal" :page-size="page.pageSize"
:layout="layout" /> :total="getListApi ? total : tableTotal"
:layout="layout"
/>
</div> </div>
</template> </template>
...@@ -161,7 +195,7 @@ ...@@ -161,7 +195,7 @@
import TableHeadSearch from "./TableHeadSearch" import TableHeadSearch from "./TableHeadSearch"
export default { export default {
name: "D2Table", name: "D2Table",
data() { data () {
return { return {
loading: false, loading: false,
data: [], data: [],
...@@ -318,7 +352,7 @@ export default { ...@@ -318,7 +352,7 @@ export default {
} }
}, },
mounted() { mounted () {
const btn = document.getElementById(this.tableParams.btnId) const btn = document.getElementById(this.tableParams.btnId)
btn && btn.addEventListener("click", this.refreshEmit) btn && btn.addEventListener("click", this.refreshEmit)
this.getListApi && this.refreshTable() this.getListApi && this.refreshTable()
...@@ -326,32 +360,32 @@ export default { ...@@ -326,32 +360,32 @@ export default {
methods: { methods: {
// 排序 // 排序
sortChange({ column, prop, order }) { sortChange ({ column, prop, order }) {
this.sortColum = order ? prop : "" this.sortColum = order ? prop : ""
this.sort = order this.sort = order
this.refreshTable(true, true) this.refreshTable(true, true)
}, },
// 多选 // 多选
handleSelect(val) { handleSelect (val) {
this.mutiSelectArr[this.tableParams.mutiSelectName] = val this.mutiSelectArr[this.tableParams.mutiSelectName] = val
// 多选 // 多选
this.$emit("selectionTable", val) this.$emit("selectionTable", val)
}, },
// 清空多选 // 清空多选
clearMutiSelect() { clearMutiSelect () {
this.mutiSelectArr[this.tableParams.mutiSelectName] = [] this.mutiSelectArr[this.tableParams.mutiSelectName] = []
this.$refs[this.tableParams.mutiSelectName + "MutiTable"].clearSelection() this.$refs[this.tableParams.mutiSelectName + "MutiTable"].clearSelection()
}, },
// 发布事件,以期查询条件改变后,页面图表需要刷新 // 发布事件,以期查询条件改变后,页面图表需要刷新
refreshEmit() { refreshEmit () {
this.$emit("searchChange") this.$emit("searchChange")
this.refreshTable(true, true) this.refreshTable(true, true)
}, },
refreshTable(clearMuti = false, resetCurrentPage = false) { refreshTable (clearMuti = false, resetCurrentPage = false) {
this.beforeSearchFn().then((res) => { this.beforeSearchFn().then((res) => {
// console.log(res) // console.log(res)
// 清空多选 // 清空多选
...@@ -444,12 +478,12 @@ export default { ...@@ -444,12 +478,12 @@ export default {
}, },
// 表头搜索项-改变 // 表头搜索项-改变
handleTableHeadChange(obj) { handleTableHeadChange (obj) {
this.$emit("handleTableHeadChange", obj) this.$emit("handleTableHeadChange", obj)
}, },
// 每页条数 // 每页条数
handleSizeChange(value) { handleSizeChange (value) {
this.page.pageSize = value this.page.pageSize = value
this.getListApi this.getListApi
? this.refreshTable(false) ? this.refreshTable(false)
...@@ -457,18 +491,18 @@ export default { ...@@ -457,18 +491,18 @@ export default {
}, },
// 页码 // 页码
handleCurrentChange(value) { handleCurrentChange (value) {
this.page.currentPage = value this.page.currentPage = value
this.getListApi this.getListApi
? this.refreshTable(false) ? this.refreshTable(false)
: this.$emit("refreshTable", this.page) : this.$emit("refreshTable", this.page)
}, },
// 重置请求 // 重置请求
resetRefreshTable() { resetRefreshTable () {
this.refreshTable_noApi() this.refreshTable_noApi()
this.refreshTable() this.refreshTable()
}, },
refreshTable_noApi() { refreshTable_noApi () {
this.page = { this.page = {
pageSize: 10, pageSize: 10,
currentPage: 1 currentPage: 1
......
...@@ -306,5 +306,29 @@ export const routerName = { ...@@ -306,5 +306,29 @@ export const routerName = {
}, },
auth: [], auth: [],
component: _import("contentManager/packageConfig/edit") component: _import("contentManager/packageConfig/edit")
} },
91315: {
path: "/customerTags",
name: "customerTags",
meta: {
title: "客户标签",
authId: "91315",
parentId: "913",
cache: false
},
auth: [],
component: _import("contentManager/customerTags/index")
},
91317: {
path: "/customerFile",
name: "customerFile",
meta: {
title: "客户档案",
authId: "91317",
parentId: "913",
cache: false
},
auth: [],
component: _import("contentManager/customerFile/index")
},
} }
<template>
<div>
客户档案
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: '',
data () {
return {
}
},
mounted () {
},
methods: {
}
}
</script>
<style scoped lang='scss'>
</style>
\ No newline at end of file \ No newline at end of file
<template>
<d2-dialog
title="新增分类"
:is-visible="visible"
width="40%"
@closeDialog="handleClose"
@confirmDialog="handleConfirm"
>
<div
class="classify-box"
v-loading="loading"
>
<el-form
ref="classifyForm"
:model="dataForm"
:rules="formRules"
label-width="154px"
size="small"
>
<el-form-item
label="一级分类:"
prop="labelName"
>
<el-input
v-model="dataForm.labelName"
placeholder="请输入"
maxlength="30"
/>
</el-form-item>
<el-form-item
label="业务类型:"
prop="scene"
>
<el-select
v-model="dataForm.scene"
placeholder="请选择"
:disabled="currentItem.id"
>
<el-option
v-for="(subItem, subIndex) in businessTypeList"
:key="subIndex"
:value="subItem.id"
:label="subItem.label"
></el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</d2-dialog>
</template>
<script type='text/ecmascript-6'>
import { deepClone } from '@/common/util'
import { SCENE_OPTIONS } from "../../constant"
import { addCustomerLabel, updateCustomerLabel } from '@api/contentManager'
export default {
name: 'classifyDialog',
props: {
visible: Boolean,
currentItem: Object
},
data () {
return {
loading: false,
businessTypeList: deepClone(SCENE_OPTIONS),
dataForm: {
labelName: '',
scene: ''
},
formRules: {
labelName: [{ required: true, message: '请输入一级分类', trigger: 'change' }],
scene: [{ required: true, message: '请选择业务类型', trigger: 'change' }],
}
}
},
watch: {
currentItem: {
immediate: true,
handler (newval) {
this.dataForm.scene = newval.scene
this.dataForm.labelName = newval.labelName
}
}
},
mounted () {
},
methods: {
handleClose () {
this.dataForm = this.$options.data.call(this).dataForm
this.$refs.classifyForm.resetFields()
this.loading = false
this.$emit('update:visible', false)
this.$emit('update:currentItem', {})
},
handleConfirm () {
this.$refs.classifyForm.validate(async (valid) => {
if (valid) {
try {
let targetApiName = addCustomerLabel,
params = {
level: 1,
...this.dataForm
},
{ id } = this.currentItem
if (id) {
targetApiName = updateCustomerLabel
params = {
id,
labelName: this.dataForm.labelName
}
}
this.loading = true
const res = await targetApiName(params)
console.log(res)
if (res) {
this.$message.success(id ? '修改成功' : '保存成功')
this.$emit('refresh')
this.handleClose()
this.loading = false
}
} catch (error) {
console.log(error)
this.loading = false
this.$message.error(error)
}
}
})
},
}
}
</script>
<style scoped lang='scss'>
.el-input,
.el-input--small {
width: 215px;
}
</style>
\ No newline at end of file \ No newline at end of file
<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 title="标签列表">
<el-button
@click="classifyVisible = true"
size="small"
type="primary"
>
新增分类
</el-button>
</d2-table-header>
<el-table
:data="tableData"
border
highlight-current-row
:tree-props="{ children: 'nextList' }"
row-key="id"
ref="table"
>
<template v-for="(item, index) in tableParams.tableColumns">
<el-table-column
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
align="center"
>
<template slot-scope="scope">
<div
v-if="item.addHtml"
:key="tableKey"
>
<template v-if="scope.row.level == 2 && scope.row.isEdit">
<el-input
v-model="scope.row[item.addHtml]"
:maxlength="item.maxlength"
:placeholder="item.placeholder"
:ref="`${scope.row.id}`"
size="small"
:class="scope.row.className"
></el-input>
</template>
<template v-else>
{{ scope.row[item.addHtml] || "-" }}
</template>
</div>
<template v-else-if="item.formatter">
<span
v-if="item.html"
v-html="item.formatter(scope.row)"
/>
<template v-if="!item.html">
<span :class="item.className ? item.className(scope.row) : ''" />
<span v-text="item.formatter(scope.row)" />
</template>
</template>
<template v-else-if="item.type == 'ownSerialNum'">
<span>{{ scope.row[item.prop] || '' }}</span>
</template>
<span v-else>{{ scope.row[item.prop] || "-" }}</span>
</template>
</el-table-column>
</template>
<el-table-column
label="操作"
fixed="right"
:align="tableParams.tableOption.align || 'center'"
:width="tableParams.tableOption.width || 'auto'"
>
<template slot-scope="scope">
<template v-if="showStatusBtn(scope.row)">
<el-button
type="text"
@click="changeStatus(scope.row)"
>
{{scope.row.status == 0 ?'停用':'启用'}}
</el-button>
<el-button
type="text"
@click="edit(scope)"
>编辑</el-button>
</template>
<el-button
v-if="scope.row.level == 1"
type="text"
@click="handleCreateChild(scope.row)"
>创建下级</el-button>
<template v-if="scope.row.isEdit">
<el-button
type="text"
@click="save(scope.row)"
>保存</el-button>
<el-button
type="text"
@click="cancel(scope.row)"
>取消</el-button>
</template>
</template>
</el-table-column>
<div
slot="empty"
class="emptyBg"
>
<img
class="noDataImg"
:src="noDataImg"
/>
暂无客户标签
</div>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.currentPage"
:page-sizes="[10, 20, 30, 40]"
:page-size="page.pageSize"
:total="tableTotal"
layout="sizes,total,->,prev,pager,next,jumper"
/>
</div>
<classify-dialog
:visible.sync="classifyVisible"
@refresh="handleReset"
:currentItem.sync="currentItem"
/>
</d2-container>
</template>
<script type='text/ecmascript-6'>
import { Util, deepClone } from '@/common/util'
import { SCENE_OPTIONS } from "../constant"
import { getCustomerLabelPage, addCustomerLabel, updateCustomerLabel } from '@api/contentManager'
import noDataImg from "@/assets/empty.png"
import classifyDialog from './components/classifyDialog.vue'
export default {
name: 'customerTags',
components: { classifyDialog },
data () {
return {
noDataImg,
classifyVisible: false,
searchForm: {
labelName: '',
scene: '',
status: '',
},
currentItem: {},
showFormData: [{
label: '标签名称',
name: 'labelName',
type: 'input',
isClear: true,
}, {
label: '业务类型',
name: 'scene',
type: 'select',
optionList: deepClone([{
id: "",
label: "全部"
}, ...SCENE_OPTIONS]),
optionId: "id",
optionLabel: "label"
}, {
label: '是否生效',
name: 'status',
type: 'select',
optionList: [
{
label: "全部",
id: ""
},
{
label: "启用",
id: "0"
},
{
label: "停用",
id: "-1"
}
],
optionId: "id",
optionLabel: "label"
}],
page: {
pageSize: 10,
currentPage: 1
},
tableTotal: 0,
tableData: [],
// 表格参数
tableParams: {
listName: 'list',
tableOption: {
width: '170'
},
tableColumns: [
{
label: '序号',
prop: 'num',
type: 'ownSerialNum',
width: 60,
}, {
label: '一级分类',
addHtml: 'labelName',
minwidth: 220,
maxlength: 30,
placeholder: '请输入'
}, {
label: '业务类型',
minwidth: 220,
formatter: (cellValue) => {
return SCENE_OPTIONS.find(e => e.id == cellValue.scene)?.label || '-'
},
}, {
label: '修改时间',
formatter: (cellValue) => {
return cellValue.updatedDate ? Util.dateFormate(cellValue.updatedDate, 'YYYY-MM-DD HH:mm:ss') : '-'
},
minwidth: 220
}, {
label: '生效时间',
formatter: (cellValue) => {
return cellValue.status == -1 ? '-' : cellValue.effectiveTime ? Util.dateFormate(cellValue.effectiveTime, 'YYYY-MM-DD HH:mm:ss') : '-'
},
minwidth: 220
}
]
},
tableKey: Date.now()
}
},
created () {
this.handleSearch()
},
mounted () {
},
methods: {
handleSearch () {
this.page = this.$options.data.call(this).page
this.getTableList()
},
handleReset () {
this.searchForm = this.$options.data.call(this).searchForm
this.tableData = []
this.handleSearch()
},
async getTableList () {
try {
const { total, list } = await getCustomerLabelPage({
...this.page,
...this.searchForm
})
console.log(list)
list.map((e, index) => e.num = this.indexNum(index))
this.tableTotal = total
this.tableData = list
} catch (error) {
if (error) this.$message.error(error)
}
},
// 每页条数
handleSizeChange (value) {
this.page.pageSize = value
this.getTableList()
},
// 页码
handleCurrentChange (value) {
this.page.currentPage = value
this.getTableList()
},
indexNum (index) {
return index + 1 + this.page.pageSize * (this.page.currentPage - 1)
},
handleCreateChild (row) {
let index = this.tableData.findIndex(i => i.id == row.id),
item = this.tableData[index],
childrenId = Date.now(),
childrenItem = {
id: childrenId,
isEdit: true,
level: 2,
labelName: '',
scene: row.scene,
parentId: row.id,
editId: childrenId
}
if (item.nextList && item.nextList.length) item.nextList.unshift(childrenItem)
else item.nextList = [childrenItem]
this.$nextTick(() => {
this.$refs.table.toggleRowExpansion(row, true)
setTimeout(() => {
this.$refs[childrenId][0].focus()
}, 100)
})
},
edit (e) {
let { row } = e
if (row.level == 1) {
this.classifyVisible = true
this.currentItem = row
}
else {
row.originLabel = row.labelName
row.isEdit = true
this.tableKey = Date.now()
setTimeout(() => {
this.$refs[row.id][0].focus()
}, 100)
}
},
async changeStatus (e) {
try {
const { id, labelName, status } = e,
res = await updateCustomerLabel({
id,
labelName,
status: status == 0 ? -1 : 0
})
if (res) {
this.$message.success(status == 0 ? '停用成功' : '启用成功')
this.handleSearch()
}
} catch (error) {
this.$message.error(error)
}
},
showStatusBtn (row) {
let show = true
if (row.level != 1 && row.isEdit) show = false
return show
},
cancel (row) {
let index = this.tableData.findIndex(i => i.id == row.parentId),
item = this.tableData[index],
childrenIndex = item.nextList.findIndex(i => i.id == row.id)
if (row.editId) item.nextList.splice(childrenIndex, 1)
else {
row.isEdit = false
row.labelName = row.originLabel
this.tableKey = Date.now()
}
},
async save (row) {
try {
let { labelName, editId, id, scene, parentId } = row,
targetApiName = addCustomerLabel,
params = {
level: 2,
labelName,
scene,
parentId
}
row.className = !labelName ? 'error-input' : ''
if (!labelName) return this.tableKey = Date.now()
if (!editId) {
targetApiName = updateCustomerLabel
params = {
id,
labelName
}
}
const res = await targetApiName(params)
if (res) {
this.$message.success(!editId ? '修改成功' : '保存成功')
this.handleSearch()
}
} catch (error) {
this.$message.error(error)
}
}
}
}
</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;
}
}
</style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!