From 5fb3dcbaeddfe1c0a93ac9cf83a12e56733be8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E8=90=BD=28YangLei=29?= Date: Thu, 8 Jul 2021 17:37:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MySelect/RequestSelect.vue | 5 ++ src/components/MySelect/search_select.vue | 12 ++-- .../task_managment/center/common/index.js | 17 ------ .../xunjian/task_managment/center/form.vue | 17 ++---- .../xunjian/task_managment/center/index.vue | 61 +++++++++++-------- 5 files changed, 53 insertions(+), 59 deletions(-) delete mode 100644 src/pages/xunjian/task_managment/center/common/index.js diff --git a/src/components/MySelect/RequestSelect.vue b/src/components/MySelect/RequestSelect.vue index cce16fe..57228ac 100644 --- a/src/components/MySelect/RequestSelect.vue +++ b/src/components/MySelect/RequestSelect.vue @@ -24,6 +24,8 @@ export default { request: Function, formatData: { type: Object, default: undefined }, getName: Function, + labelFiled: String, // 和 formatData 一样 传一种就行了 + valueFiled: String, }, data() { return { @@ -34,6 +36,9 @@ export default { if (this.request) { const newArr = await this.request(); this.data = this.formatData ? await formatObj(newArr, this.formatData) : newArr; + this.data = this.labelFiled + ? formatObj(newArr, { label: this.labelFiled, value: this.valueFiled, key: this.valueFiled }) + : this.data; } }, methods: { diff --git a/src/components/MySelect/search_select.vue b/src/components/MySelect/search_select.vue index 52b9877..2ae0aae 100644 --- a/src/components/MySelect/search_select.vue +++ b/src/components/MySelect/search_select.vue @@ -21,8 +21,9 @@ export default { props: { url: String, searchField: String, - formatData: Object, mode: String, + labelFiled: String, + valueFiled: String, }, model: { prop: 'value', @@ -38,10 +39,11 @@ export default { }, methods: { async getData(searchString) { - this.options = formatObj( - await getReq(this.url, { [this.searchField]: searchString }), - this.formatData, - ); + this.options = formatObj(await getReq(this.url, { [this.searchField]: searchString }), { + label: this.labelFiled, + value: this.valueFiled, + key: this.valueFiled, + }); }, handleSearch(value) { if (this.timeOut) clearTimeout(this.timeOut); diff --git a/src/pages/xunjian/task_managment/center/common/index.js b/src/pages/xunjian/task_managment/center/common/index.js deleted file mode 100644 index 610a23d..0000000 --- a/src/pages/xunjian/task_managment/center/common/index.js +++ /dev/null @@ -1,17 +0,0 @@ -export const areaFormatData = { - label: 'regionName', - value: 'regionId', - key: 'regionId', -}; - -export const statusFormtData = { - label: 'paramName', - value: 'paramValue', - key: 'paramValue', -}; - -export const banZuFormatData = { - label: 'paramName', - value: 'paramValue', - key: 'paramValue', -}; diff --git a/src/pages/xunjian/task_managment/center/form.vue b/src/pages/xunjian/task_managment/center/form.vue index a2e5282..d92ed28 100644 --- a/src/pages/xunjian/task_managment/center/form.vue +++ b/src/pages/xunjian/task_managment/center/form.vue @@ -4,8 +4,9 @@ @@ -21,8 +22,9 @@ @@ -39,7 +41,8 @@ @@ -54,7 +57,6 @@ import RequestSelect from '@/components/MySelect/RequestSelect.vue'; import SearchSelect from '@/components/MySelect/search_select.vue'; import UrlSelect from '@/components/MySelect/url_select.vue'; import { getAreaListDataApi, getBanZuListApi, addXunJianTaskApi } from '@/api'; -import { areaFormatData, banZuFormatData } from './common'; export default { props: { @@ -65,7 +67,6 @@ export default { data() { return { getAreaListDataApi, - banZuFormatData, getBanZuListApi, form: {}, rules: { @@ -75,12 +76,6 @@ export default { routeId: [{ required: true }], regionId: [{ required: true }], }, - areaFormatData, - formatXunJianRenData: { - value: 'userId', - label: 'userName', - key: 'userId', - }, }; }, computed: { diff --git a/src/pages/xunjian/task_managment/center/index.vue b/src/pages/xunjian/task_managment/center/index.vue index 5dabdc5..7cd9668 100644 --- a/src/pages/xunjian/task_managment/center/index.vue +++ b/src/pages/xunjian/task_managment/center/index.vue @@ -19,57 +19,73 @@ - - - @@ -98,20 +114,20 @@