index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <zj-page-container direction="row">
  3. <div style="min-width: 240px; max-width: 240px; height: 100%">
  4. <zj-page-container>
  5. <div class="title">
  6. <el-button style="margin-right: 5px" size="mini" icon="el-icon-search" @click="getTreeListData"></el-button>
  7. <el-input size="mini" v-model="filterText" placeholder="请输入内容"></el-input>
  8. </div>
  9. <zj-page-fill>
  10. <el-tree
  11. :data="treeList"
  12. :props="defaultProps"
  13. default-expand-all
  14. :highlight-current="true"
  15. :expand-on-click-node="false"
  16. @node-click="handleNodeClick"
  17. :filter-node-method="filterNode"
  18. ref="listTree"
  19. >
  20. <span class="custom-tree-node" slot-scope="{ node }">
  21. <span>{{ node.label }}</span>
  22. </span>
  23. </el-tree>
  24. </zj-page-fill>
  25. </zj-page-container>
  26. </div>
  27. <template-page
  28. ref="pageRef"
  29. :getList="getList"
  30. :columnParsing="columnParsing"
  31. :optionsEvensGroup="optionsEvensGroup"
  32. :tableAttributes="tableAttributes"
  33. :tableEvents="tableEvents"
  34. :operationColumnWidth="160"
  35. :operation="operation()"
  36. :exportList="exportList"
  37. >
  38. </template-page>
  39. <div class="cartographer_big">
  40. <el-dialog title="配置" width="100%" :modal="false" :visible.sync="formDialog" :before-close="formDialogClose">
  41. <zj-page-container v-if="formDialog">
  42. <zj-page-fill class="neibuview">
  43. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  44. <zj-form-module title="配置信息" label-width="90px" :form-data="formData" :form-items="formItems">
  45. </zj-form-module>
  46. </zj-form-container>
  47. </zj-page-fill>
  48. <div>
  49. <div style="box-sizing: border-box; padding: 10px">
  50. <el-button size="mini" @click="formDialogClose">关闭</el-button>
  51. <el-button size="mini" type="primary" @click="queding">确定</el-button>
  52. </div>
  53. </div>
  54. </zj-page-container>
  55. </el-dialog>
  56. </div>
  57. </zj-page-container>
  58. </template>
  59. <script>
  60. import TemplatePage from '@/components/template/template-page-1.vue'
  61. import {
  62. dispatchListDispatch,
  63. dispatchListDispatchExport,
  64. dispatchDelDispatch,
  65. dispatchImport,
  66. dispatchPList,
  67. dispatchCList,
  68. dispatchAList,
  69. dispatchSList,
  70. dispatchChannel,
  71. dispatchSmallList,
  72. dispatchCategoryList,
  73. dispatchSourceList,
  74. dispatchSaveDispatch
  75. } from '@/api/streetConfiguration.js'
  76. import operation_mixin from '@/components/template/operation_mixin.js'
  77. import import_mixin from '@/components/template/import_mixin.js'
  78. import { getDepartmentList } from '@/api/setting'
  79. import { commonTemplateDownload } from '@/api/common.js'
  80. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  81. export default {
  82. components: {
  83. TemplatePage
  84. },
  85. mixins: [operation_mixin, import_mixin],
  86. data() {
  87. return {
  88. // 表格属性
  89. tableAttributes: {},
  90. // 表格事件
  91. tableEvents: {},
  92. visible: false,
  93. item: null,
  94. treeList: [],
  95. defaultProps: {
  96. children: 'children',
  97. label: 'name'
  98. },
  99. filterText: '',
  100. dataList: [],
  101. provinceList: [],
  102. cityList: [],
  103. areaList: [],
  104. streetList: [],
  105. orderSourceIdsList: [],
  106. orderSmallIdsList: [],
  107. orderChannelIdsList: [],
  108. categoryIdsList: [],
  109. formData: {
  110. provinceCode: '',
  111. provinceName: '',
  112. cityCode: '',
  113. cityName: '',
  114. areaCode: '',
  115. areaName: '',
  116. streetCode: '',
  117. streetName: '',
  118. categoryIds: [],
  119. orderChannelIds: [],
  120. orderSmallIds: [],
  121. orderSourceIds: [],
  122. websitId: '',
  123. websitName: ''
  124. },
  125. formDialog: false
  126. }
  127. },
  128. mounted() {
  129. this.getTreeListData()
  130. },
  131. computed: {
  132. // 事件组合
  133. optionsEvensGroup() {
  134. return [
  135. [
  136. [
  137. this.optionsEvensAuth('add', {
  138. click: () => {
  139. this.formDialog = true
  140. }
  141. })
  142. ],
  143. [
  144. this.optionsEvensAuth('downloadImportTemplate', {
  145. click: () => {
  146. commonTemplateDownload({ name: '自动派工配置.xlsx' }, `自动派工配置`)
  147. .then(res => {
  148. this.$message({
  149. message: '下载成功',
  150. type: 'success'
  151. })
  152. })
  153. .catch(err => {
  154. this.$message.error('下载失败')
  155. })
  156. }
  157. })
  158. ],
  159. [
  160. this.optionsEvensAuth('import', ({ moduleName }) => {
  161. return {
  162. name: moduleName,
  163. render: () => {
  164. return this.importButton(dispatchImport, moduleName)
  165. }
  166. }
  167. })
  168. ]
  169. ]
  170. ]
  171. },
  172. formItems() {
  173. return [
  174. {
  175. name: 'el-select',
  176. md: 6,
  177. options: this.dataList,
  178. attributes: {
  179. placeholder: '请选择',
  180. clearable: true,
  181. filterable: true
  182. },
  183. formItemAttributes: {
  184. label: '选择网点',
  185. prop: 'websitId',
  186. rules: [...required]
  187. },
  188. events: {
  189. change: val => {
  190. if (val) {
  191. this.formData.websitName = this.dataList.find(item => item.value == val).label
  192. } else {
  193. this.formData.websitName = ''
  194. }
  195. }
  196. }
  197. },
  198. {
  199. name: 'el-select',
  200. md: 6,
  201. formItemAttributes: {
  202. label: '选择省份', //省
  203. prop: 'provinceCode',
  204. rules: [...required],
  205. errLabel: '省'
  206. },
  207. options: this.provinceList,
  208. attributes: {
  209. clearable: true,
  210. filterable: true,
  211. placeholder: '请选择',
  212. loading: !this.provinceList.length
  213. },
  214. events: {
  215. focus: val => {
  216. dispatchPList(this.getPam('provinceCode')).then(res => {
  217. this.provinceList = res.data.map(item => ({
  218. value: item.keyId,
  219. label: item.valueName
  220. }))
  221. })
  222. },
  223. change: val => {
  224. // 获取省名称
  225. this.formData.provinceName = this.provinceList?.find(item => item.value === val)?.label || ''
  226. }
  227. }
  228. },
  229. {
  230. name: 'el-select',
  231. md: 6,
  232. formItemAttributes: {
  233. label: '选择城市', //市
  234. prop: 'cityCode',
  235. rules: [...required],
  236. errLabel: '市'
  237. },
  238. options: this.cityList,
  239. attributes: {
  240. clearable: true,
  241. filterable: true,
  242. placeholder: '请选择',
  243. loading: !this.cityList.length
  244. },
  245. events: {
  246. focus: val => {
  247. dispatchCList(this.getPam('cityCode')).then(res => {
  248. this.cityList = res.data.map(item => ({
  249. value: item.keyId,
  250. label: item.valueName
  251. }))
  252. })
  253. },
  254. change: val => {
  255. // 获取市名称
  256. this.formData.cityName = this.cityList?.find(item => item.value === val)?.label || ''
  257. }
  258. }
  259. },
  260. {
  261. name: 'el-select',
  262. md: 6,
  263. formItemAttributes: {
  264. label: '选择区域', //区
  265. prop: 'areaCode',
  266. rules: [...required],
  267. errLabel: '区'
  268. },
  269. options: this.areaList,
  270. attributes: {
  271. clearable: true,
  272. filterable: true,
  273. placeholder: '请选择',
  274. loading: !this.areaList.length
  275. },
  276. events: {
  277. focus: val => {
  278. dispatchAList(this.getPam('areaCode')).then(res => {
  279. this.areaList = res.data.map(item => ({
  280. value: item.keyId,
  281. label: item.valueName
  282. }))
  283. })
  284. },
  285. change: val => {
  286. // 获取区名称
  287. this.formData.areaName = this.areaList?.find(item => item.value === val)?.label || ''
  288. }
  289. }
  290. },
  291. {
  292. name: 'el-select',
  293. md: 6,
  294. formItemAttributes: {
  295. label: '选择街道', //街道
  296. prop: 'streetCode',
  297. rules: [...required],
  298. errLabel: '街道'
  299. },
  300. options: this.streetList,
  301. attributes: {
  302. clearable: true,
  303. filterable: true,
  304. placeholder: '请选择',
  305. loading: !this.streetList.length
  306. },
  307. events: {
  308. focus: val => {
  309. dispatchSList(this.getPam('streetCode')).then(res => {
  310. this.streetList = res.data.map(item => ({
  311. value: item.keyId,
  312. label: item.valueName
  313. }))
  314. })
  315. },
  316. change: val => {
  317. // 获取街道名称
  318. this.formData.streetName = this.streetList?.find(item => item.value === val)?.label || ''
  319. }
  320. }
  321. },
  322. {
  323. name: 'zj-paging-pull-down',
  324. options: this.orderChannelIdsList,
  325. md: 24,
  326. attributes: {
  327. placeholder: '请选择',
  328. clearable: true,
  329. filterable: true,
  330. multiple: true,
  331. loading: !this.orderChannelIdsList.length
  332. },
  333. formItemAttributes: {
  334. label: '工单渠道',
  335. prop: 'orderChannelIds',
  336. rules: [...required]
  337. },
  338. events: {
  339. focus: val => {
  340. dispatchChannel(this.getPam('orderChannelIds')).then(res => {
  341. this.orderChannelIdsList = res.data.map(item => ({
  342. value: item.keyId,
  343. label: item.valueName
  344. }))
  345. })
  346. }
  347. }
  348. },
  349. {
  350. name: 'zj-paging-pull-down',
  351. options: this.orderSmallIdsList,
  352. md: 24,
  353. attributes: {
  354. placeholder: '请选择',
  355. clearable: true,
  356. filterable: true,
  357. multiple: true,
  358. loading: !this.orderSmallIdsList.length
  359. },
  360. formItemAttributes: {
  361. label: '工单类型',
  362. prop: 'orderSmallIds',
  363. rules: [...required]
  364. },
  365. events: {
  366. focus: val => {
  367. dispatchSmallList(this.getPam('orderSmallIds')).then(res => {
  368. this.orderSmallIdsList = res.data.map(item => ({
  369. value: item.keyId,
  370. label: item.valueName
  371. }))
  372. })
  373. }
  374. }
  375. },
  376. {
  377. name: 'zj-paging-pull-down',
  378. options: this.categoryIdsList,
  379. md: 24,
  380. attributes: {
  381. placeholder: '请选择',
  382. clearable: true,
  383. filterable: true,
  384. multiple: true,
  385. loading: !this.categoryIdsList.length
  386. },
  387. formItemAttributes: {
  388. label: '产品大类',
  389. prop: 'categoryIds',
  390. rules: [...required]
  391. },
  392. events: {
  393. focus: val => {
  394. dispatchCategoryList(this.getPam('categoryIds')).then(res => {
  395. this.categoryIdsList = res.data.map(item => ({
  396. value: item.keyId,
  397. label: item.valueName
  398. }))
  399. })
  400. }
  401. }
  402. },
  403. {
  404. name: 'zj-paging-pull-down',
  405. options: this.orderSourceIdsList,
  406. md: 24,
  407. attributes: {
  408. placeholder: '请选择',
  409. clearable: true,
  410. filterable: true,
  411. multiple: true,
  412. loading: !this.orderSourceIdsList.length
  413. },
  414. formItemAttributes: {
  415. label: '工单来源',
  416. prop: 'orderSourceIds',
  417. rules: [...required]
  418. },
  419. events: {
  420. focus: val => {
  421. dispatchSourceList(this.getPam('orderSourceIds')).then(res => {
  422. this.orderSourceIdsList = res.data.map(item => ({
  423. value: item.keyId,
  424. label: item.valueName
  425. }))
  426. })
  427. }
  428. }
  429. }
  430. ]
  431. }
  432. },
  433. watch: {
  434. filterText(val) {
  435. this?.$refs?.listTree?.filter?.(val)
  436. }
  437. },
  438. methods: {
  439. filterNode(value, data) {
  440. if (!value) return true
  441. return data.name.indexOf(value) !== -1
  442. },
  443. // 请求属性数据
  444. getTreeListData() {
  445. var list_ = []
  446. function dg(list, pname = []) {
  447. for (let { children, name, ...item } of list) {
  448. list_.push({ ...item, name: name, pname: [...pname] })
  449. if (children && children.length) dg(children, [...pname, name])
  450. }
  451. }
  452. getDepartmentList().then(res => {
  453. this.treeList = res.data
  454. this.$refs.pageRef.refreshList()
  455. dg(JSON.parse(JSON.stringify(res.data)))
  456. this.dataList = [...list_]
  457. .filter(item => {
  458. return item.type === 'C'
  459. })
  460. .map(item => {
  461. return {
  462. label: item.name,
  463. value: item.websitId
  464. }
  465. })
  466. })
  467. },
  468. // 树形选中
  469. handleNodeClick(e) {
  470. this.$refs.pageRef.refreshList()
  471. },
  472. // 列表请求函数
  473. getList(pam, cb) {
  474. try {
  475. cb && cb(pam)
  476. return dispatchListDispatch(pam)
  477. } catch (err) {}
  478. },
  479. // 列表导出函数
  480. exportList: dispatchListDispatchExport,
  481. // 表格列解析渲染数据更改
  482. columnParsing(item, defaultData) {
  483. return defaultData
  484. },
  485. operation() {
  486. return this.operationBtn({
  487. // edit: {
  488. // click: ({ row, index, column }) => {}
  489. // },
  490. del: {
  491. prompt: '请确认是否删除该数据, 是否继续?',
  492. click: ({ row, index, column }) => {
  493. dispatchDelDispatch({
  494. id: row.id
  495. }).then(res => {
  496. if (res.code == 200) {
  497. this.$message({ type: 'success', message: '删除成功!' })
  498. this.$refs.pageRef.refreshList()
  499. } else {
  500. this.$message.error(res.msg)
  501. }
  502. })
  503. }
  504. }
  505. })
  506. },
  507. getPam(key) {
  508. var keys = [
  509. 'provinceCode',
  510. 'cityCode',
  511. 'areaCode',
  512. 'streetCode',
  513. 'dictCode',
  514. 'categoryId',
  515. 'orderSmallId',
  516. 'orderSourceId'
  517. ].filter(k => k !== key)
  518. var obj = {}
  519. keys.map(k => {
  520. if (this.formData[k]) {
  521. obj[k] = this.formData[k]
  522. }
  523. })
  524. // console.
  525. return obj
  526. },
  527. formDialogClose() {
  528. // this.provinceList: [],
  529. // cityList: [],
  530. // areaList: [],
  531. // streetList: [],
  532. this.formData = {
  533. provinceCode: '',
  534. provinceName: '',
  535. cityCode: '',
  536. cityName: '',
  537. areaCode: '',
  538. areaName: '',
  539. streetCode: '',
  540. streetName: '',
  541. categoryId: '',
  542. categoryName: '',
  543. dictCode: '',
  544. dictValue: '',
  545. orderSmallId: '',
  546. orderSmallTypeText: '',
  547. orderSource: '',
  548. orderSourceId: '',
  549. websitId: '',
  550. websitName: ''
  551. }
  552. this.formDialog = false
  553. },
  554. queding() {
  555. this.$refs.formRef.validate(valid => {
  556. if (valid) {
  557. dispatchSaveDispatch(this.formData).then(res => {
  558. this.$message({ type: 'success', message: `配置成功!` })
  559. this.$refs.pageRef.refreshList()
  560. this.formDialogClose()
  561. })
  562. }
  563. })
  564. }
  565. }
  566. }
  567. </script>
  568. <style lang="scss" scoped>
  569. .title {
  570. width: 100%;
  571. padding: 20px 0 10px 20px;
  572. display: flex;
  573. justify-content: space-between;
  574. margin-bottom: 10px;
  575. border-bottom: 1px solid #cccccc;
  576. font-weight: bold;
  577. }
  578. .custom-tree-node {
  579. display: inline-block;
  580. width: 100%;
  581. overflow: hidden;
  582. text-overflow: ellipsis;
  583. white-space: nowrap;
  584. }
  585. .neibuview {
  586. box-sizing: border-box;
  587. padding-left: 16px;
  588. ::v-deep & > .zj-page-fill-scroll {
  589. box-sizing: border-box;
  590. padding-right: 16px;
  591. & > div:nth-child(1) {
  592. margin-top: 20px;
  593. }
  594. }
  595. }
  596. </style>