123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600 |
- <template>
- <zj-page-container direction="row">
- <div style="min-width: 240px; max-width: 240px; height: 100%">
- <zj-page-container>
- <div class="title">
- <el-button style="margin-right: 5px" size="mini" icon="el-icon-search" @click="getTreeListData"></el-button>
- <el-input size="mini" v-model="filterText" placeholder="请输入内容"></el-input>
- </div>
- <zj-page-fill>
- <el-tree
- :data="treeList"
- :props="defaultProps"
- default-expand-all
- :highlight-current="true"
- :expand-on-click-node="false"
- @node-click="handleNodeClick"
- :filter-node-method="filterNode"
- ref="listTree"
- >
- <span class="custom-tree-node" slot-scope="{ node }">
- <span>{{ node.label }}</span>
- </span>
- </el-tree>
- </zj-page-fill>
- </zj-page-container>
- </div>
- <template-page
- ref="pageRef"
- :getList="getList"
- :columnParsing="columnParsing"
- :optionsEvensGroup="optionsEvensGroup"
- :tableAttributes="tableAttributes"
- :tableEvents="tableEvents"
- :operationColumnWidth="160"
- :operation="operation()"
- :exportList="exportList"
- >
- </template-page>
- <div class="cartographer_big">
- <el-dialog title="配置" width="100%" :modal="false" :visible.sync="formDialog" :before-close="formDialogClose">
- <zj-page-container v-if="formDialog">
- <zj-page-fill class="neibuview">
- <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
- <zj-form-module title="配置信息" label-width="90px" :form-data="formData" :form-items="formItems">
- </zj-form-module>
- </zj-form-container>
- </zj-page-fill>
- <div>
- <div style="box-sizing: border-box; padding: 10px">
- <el-button size="mini" @click="formDialogClose">关闭</el-button>
- <el-button size="mini" type="primary" @click="queding">确定</el-button>
- </div>
- </div>
- </zj-page-container>
- </el-dialog>
- </div>
- </zj-page-container>
- </template>
- <script>
- import TemplatePage from '@/components/template/template-page-1.vue'
- import {
- dispatchListDispatch,
- dispatchListDispatchExport,
- dispatchDelDispatch,
- dispatchImport,
- dispatchPList,
- dispatchCList,
- dispatchAList,
- dispatchSList,
- dispatchChannel,
- dispatchSmallList,
- dispatchCategoryList,
- dispatchSourceList,
- dispatchSaveDispatch
- } from '@/api/streetConfiguration.js'
- import operation_mixin from '@/components/template/operation_mixin.js'
- import import_mixin from '@/components/template/import_mixin.js'
- import { getDepartmentList } from '@/api/setting'
- import { commonTemplateDownload } from '@/api/common.js'
- import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
- export default {
- components: {
- TemplatePage
- },
- mixins: [operation_mixin, import_mixin],
- data() {
- return {
- // 表格属性
- tableAttributes: {},
- // 表格事件
- tableEvents: {},
- visible: false,
- item: null,
- treeList: [],
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- filterText: '',
- dataList: [],
- provinceList: [],
- cityList: [],
- areaList: [],
- streetList: [],
- orderSourceIdsList: [],
- orderSmallIdsList: [],
- orderChannelIdsList: [],
- categoryIdsList: [],
- formData: {
- provinceCode: '',
- provinceName: '',
- cityCode: '',
- cityName: '',
- areaCode: '',
- areaName: '',
- streetCode: '',
- streetName: '',
- categoryIds: [],
- orderChannelIds: [],
- orderSmallIds: [],
- orderSourceIds: [],
- websitId: '',
- websitName: ''
- },
- formDialog: false
- }
- },
- mounted() {
- this.getTreeListData()
- },
- computed: {
- // 事件组合
- optionsEvensGroup() {
- return [
- [
- [
- this.optionsEvensAuth('add', {
- click: () => {
- this.formDialog = true
- }
- })
- ],
- [
- this.optionsEvensAuth('downloadImportTemplate', {
- click: () => {
- commonTemplateDownload({ name: '自动派工配置.xlsx' }, `自动派工配置`)
- .then(res => {
- this.$message({
- message: '下载成功',
- type: 'success'
- })
- })
- .catch(err => {
- this.$message.error('下载失败')
- })
- }
- })
- ],
- [
- this.optionsEvensAuth('import', ({ moduleName }) => {
- return {
- name: moduleName,
- render: () => {
- return this.importButton(dispatchImport, moduleName)
- }
- }
- })
- ]
- ]
- ]
- },
- formItems() {
- return [
- {
- name: 'el-select',
- md: 6,
- options: this.dataList,
- attributes: {
- placeholder: '请选择',
- clearable: true,
- filterable: true
- },
- formItemAttributes: {
- label: '选择网点',
- prop: 'websitId',
- rules: [...required]
- },
- events: {
- change: val => {
- if (val) {
- this.formData.websitName = this.dataList.find(item => item.value == val).label
- } else {
- this.formData.websitName = ''
- }
- }
- }
- },
- {
- name: 'el-select',
- md: 6,
- formItemAttributes: {
- label: '选择省份', //省
- prop: 'provinceCode',
- rules: [...required],
- errLabel: '省'
- },
- options: this.provinceList,
- attributes: {
- clearable: true,
- filterable: true,
- placeholder: '请选择',
- loading: !this.provinceList.length
- },
- events: {
- focus: val => {
- dispatchPList(this.getPam('provinceCode')).then(res => {
- this.provinceList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- },
- change: val => {
- // 获取省名称
- this.formData.provinceName = this.provinceList?.find(item => item.value === val)?.label || ''
- }
- }
- },
- {
- name: 'el-select',
- md: 6,
- formItemAttributes: {
- label: '选择城市', //市
- prop: 'cityCode',
- rules: [...required],
- errLabel: '市'
- },
- options: this.cityList,
- attributes: {
- clearable: true,
- filterable: true,
- placeholder: '请选择',
- loading: !this.cityList.length
- },
- events: {
- focus: val => {
- dispatchCList(this.getPam('cityCode')).then(res => {
- this.cityList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- },
- change: val => {
- // 获取市名称
- this.formData.cityName = this.cityList?.find(item => item.value === val)?.label || ''
- }
- }
- },
- {
- name: 'el-select',
- md: 6,
- formItemAttributes: {
- label: '选择区域', //区
- prop: 'areaCode',
- rules: [...required],
- errLabel: '区'
- },
- options: this.areaList,
- attributes: {
- clearable: true,
- filterable: true,
- placeholder: '请选择',
- loading: !this.areaList.length
- },
- events: {
- focus: val => {
- dispatchAList(this.getPam('areaCode')).then(res => {
- this.areaList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- },
- change: val => {
- // 获取区名称
- this.formData.areaName = this.areaList?.find(item => item.value === val)?.label || ''
- }
- }
- },
- {
- name: 'el-select',
- md: 6,
- formItemAttributes: {
- label: '选择街道', //街道
- prop: 'streetCode',
- rules: [...required],
- errLabel: '街道'
- },
- options: this.streetList,
- attributes: {
- clearable: true,
- filterable: true,
- placeholder: '请选择',
- loading: !this.streetList.length
- },
- events: {
- focus: val => {
- dispatchSList(this.getPam('streetCode')).then(res => {
- this.streetList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- },
- change: val => {
- // 获取街道名称
- this.formData.streetName = this.streetList?.find(item => item.value === val)?.label || ''
- }
- }
- },
- {
- name: 'zj-paging-pull-down',
- options: this.orderChannelIdsList,
- md: 24,
- attributes: {
- placeholder: '请选择',
- clearable: true,
- filterable: true,
- multiple: true,
- loading: !this.orderChannelIdsList.length
- },
- formItemAttributes: {
- label: '工单渠道',
- prop: 'orderChannelIds',
- rules: [...required]
- },
- events: {
- focus: val => {
- dispatchChannel(this.getPam('orderChannelIds')).then(res => {
- this.orderChannelIdsList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- }
- }
- },
- {
- name: 'zj-paging-pull-down',
- options: this.orderSmallIdsList,
- md: 24,
- attributes: {
- placeholder: '请选择',
- clearable: true,
- filterable: true,
- multiple: true,
- loading: !this.orderSmallIdsList.length
- },
- formItemAttributes: {
- label: '工单类型',
- prop: 'orderSmallIds',
- rules: [...required]
- },
- events: {
- focus: val => {
- dispatchSmallList(this.getPam('orderSmallIds')).then(res => {
- this.orderSmallIdsList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- }
- }
- },
- {
- name: 'zj-paging-pull-down',
- options: this.categoryIdsList,
- md: 24,
- attributes: {
- placeholder: '请选择',
- clearable: true,
- filterable: true,
- multiple: true,
- loading: !this.categoryIdsList.length
- },
- formItemAttributes: {
- label: '产品大类',
- prop: 'categoryIds',
- rules: [...required]
- },
- events: {
- focus: val => {
- dispatchCategoryList(this.getPam('categoryIds')).then(res => {
- this.categoryIdsList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- }
- }
- },
- {
- name: 'zj-paging-pull-down',
- options: this.orderSourceIdsList,
- md: 24,
- attributes: {
- placeholder: '请选择',
- clearable: true,
- filterable: true,
- multiple: true,
- loading: !this.orderSourceIdsList.length
- },
- formItemAttributes: {
- label: '工单来源',
- prop: 'orderSourceIds',
- rules: [...required]
- },
- events: {
- focus: val => {
- dispatchSourceList(this.getPam('orderSourceIds')).then(res => {
- this.orderSourceIdsList = res.data.map(item => ({
- value: item.keyId,
- label: item.valueName
- }))
- })
- }
- }
- }
- ]
- }
- },
- watch: {
- filterText(val) {
- this?.$refs?.listTree?.filter?.(val)
- }
- },
- methods: {
- filterNode(value, data) {
- if (!value) return true
- return data.name.indexOf(value) !== -1
- },
- // 请求属性数据
- getTreeListData() {
- var list_ = []
- function dg(list, pname = []) {
- for (let { children, name, ...item } of list) {
- list_.push({ ...item, name: name, pname: [...pname] })
- if (children && children.length) dg(children, [...pname, name])
- }
- }
- getDepartmentList().then(res => {
- this.treeList = res.data
- this.$refs.pageRef.refreshList()
- dg(JSON.parse(JSON.stringify(res.data)))
- this.dataList = [...list_]
- .filter(item => {
- return item.type === 'C'
- })
- .map(item => {
- return {
- label: item.name,
- value: item.websitId
- }
- })
- })
- },
- // 树形选中
- handleNodeClick(e) {
- this.$refs.pageRef.refreshList()
- },
- // 列表请求函数
- getList(pam, cb) {
- try {
- cb && cb(pam)
- return dispatchListDispatch(pam)
- } catch (err) {}
- },
- // 列表导出函数
- exportList: dispatchListDispatchExport,
- // 表格列解析渲染数据更改
- columnParsing(item, defaultData) {
- return defaultData
- },
- operation() {
- return this.operationBtn({
- // edit: {
- // click: ({ row, index, column }) => {}
- // },
- del: {
- prompt: '请确认是否删除该数据, 是否继续?',
- click: ({ row, index, column }) => {
- dispatchDelDispatch({
- id: row.id
- }).then(res => {
- if (res.code == 200) {
- this.$message({ type: 'success', message: '删除成功!' })
- this.$refs.pageRef.refreshList()
- } else {
- this.$message.error(res.msg)
- }
- })
- }
- }
- })
- },
- getPam(key) {
- var keys = [
- 'provinceCode',
- 'cityCode',
- 'areaCode',
- 'streetCode',
- 'dictCode',
- 'categoryId',
- 'orderSmallId',
- 'orderSourceId'
- ].filter(k => k !== key)
- var obj = {}
- keys.map(k => {
- if (this.formData[k]) {
- obj[k] = this.formData[k]
- }
- })
- // console.
- return obj
- },
- formDialogClose() {
- // this.provinceList: [],
- // cityList: [],
- // areaList: [],
- // streetList: [],
- this.formData = {
- provinceCode: '',
- provinceName: '',
- cityCode: '',
- cityName: '',
- areaCode: '',
- areaName: '',
- streetCode: '',
- streetName: '',
- categoryId: '',
- categoryName: '',
- dictCode: '',
- dictValue: '',
- orderSmallId: '',
- orderSmallTypeText: '',
- orderSource: '',
- orderSourceId: '',
- websitId: '',
- websitName: ''
- }
- this.formDialog = false
- },
- queding() {
- this.$refs.formRef.validate(valid => {
- if (valid) {
- dispatchSaveDispatch(this.formData).then(res => {
- this.$message({ type: 'success', message: `配置成功!` })
- this.$refs.pageRef.refreshList()
- this.formDialogClose()
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .title {
- width: 100%;
- padding: 20px 0 10px 20px;
- display: flex;
- justify-content: space-between;
- margin-bottom: 10px;
- border-bottom: 1px solid #cccccc;
- font-weight: bold;
- }
- .custom-tree-node {
- display: inline-block;
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .neibuview {
- box-sizing: border-box;
- padding-left: 16px;
- ::v-deep & > .zj-page-fill-scroll {
- box-sizing: border-box;
- padding-right: 16px;
- & > div:nth-child(1) {
- margin-top: 20px;
- }
- }
- }
- </style>
|