From e5c832aa00401a14a4f30f700f4f37879ad4926c Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Wed, 30 Oct 2019 17:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=EF=BC=9A/a?= =?UTF-8?q?pi/mapPrd/{skinStyle}/list=20=20=E6=94=B9=E4=B8=BA=20=20/api/ma?= =?UTF-8?q?pPrd/{mapId}/list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/management/mapprd.js | 4 +- .../lessoncategory/edit/lesson/index.vue | 2 +- src/views/lesson/trainingmanage/draft.vue | 8 +- src/views/lesson/trainingmanage/index.vue | 2 +- src/views/management/userSimulation/add.vue | 334 +++++------ src/views/package/draft/editRule.vue | 563 +++++++++--------- src/views/package/draft/ruleForm.vue | 337 ++++++----- src/views/systemGenerate/create.vue | 266 ++++----- 8 files changed, 749 insertions(+), 767 deletions(-) diff --git a/src/api/management/mapprd.js b/src/api/management/mapprd.js index 427d858ae..f47c6c664 100644 --- a/src/api/management/mapprd.js +++ b/src/api/management/mapprd.js @@ -62,9 +62,9 @@ export function deleteTrainingCategory(data) { /** * 获取地图下的产品列表 */ -export function getCommodityMapProduct(skinCode) { +export function getCommodityMapProduct(mapId) { return request({ - url: `/api/mapPrd/${skinCode}/list`, + url: `/api/mapPrd/${mapId}/list`, method: 'get' }); } diff --git a/src/views/lesson/lessoncategory/edit/lesson/index.vue b/src/views/lesson/lessoncategory/edit/lesson/index.vue index 66fa12c63..d7edfe84f 100644 --- a/src/views/lesson/lessoncategory/edit/lesson/index.vue +++ b/src/views/lesson/lessoncategory/edit/lesson/index.vue @@ -119,7 +119,7 @@ export default { } else { this.courseModel.skinCode = this.$route.query.skinCode; } - getCommodityMapProduct(this.$route.query.skinCode).then(response => { + getCommodityMapProduct(this.$route.query.mapId).then(response => { this.productList = response.data || []; this.productList = this.productList.filter(elem => { return elem.prdType != '03'; }); }); diff --git a/src/views/lesson/trainingmanage/draft.vue b/src/views/lesson/trainingmanage/draft.vue index f7c69ca6b..11ca93316 100644 --- a/src/views/lesson/trainingmanage/draft.vue +++ b/src/views/lesson/trainingmanage/draft.vue @@ -197,7 +197,7 @@ export default { } }, mounted() { - this.skinCodeChoose(this.$route.params.skinCode); + this.mapIdChoose(this.$route.query.mapId); }, methods: { show(data) { @@ -211,11 +211,11 @@ export default { this.dialogShow = false; this.loading = false; }, - skinCodeChoose(skinCode) { + mapIdChoose(mapId) { this.operateModel.prdCode = ''; this.productList = []; - if (skinCode) { - getCommodityMapProduct(skinCode).then((response) => { + if (mapId) { + getCommodityMapProduct(mapId).then((response) => { this.productList = response.data; this.productList = this.productList.filter(elem => { return elem.prdType != '03'; }); }); diff --git a/src/views/lesson/trainingmanage/index.vue b/src/views/lesson/trainingmanage/index.vue index fa7c82c12..30e01bb9b 100644 --- a/src/views/lesson/trainingmanage/index.vue +++ b/src/views/lesson/trainingmanage/index.vue @@ -172,7 +172,7 @@ export default { getSkinCodeList().then(response => { this.skinCodeList = response.data; }); - getCommodityMapProduct(this.$route.params.skinCode).then((response) => { + getCommodityMapProduct(this.$route.query.mapId).then((response) => { const productList = response.data; if (productList && productList.length > 0) { productList.forEach(elem => { diff --git a/src/views/management/userSimulation/add.vue b/src/views/management/userSimulation/add.vue index 4a6ab2348..3728527b5 100644 --- a/src/views/management/userSimulation/add.vue +++ b/src/views/management/userSimulation/add.vue @@ -15,176 +15,168 @@ import { getPublishMapList } from '@/api/jmap/map'; import { getCommodityMapProduct } from '@/api/management/mapprd'; export default { - name: 'UsersTrainingAdd', - props: { - type: { - type: String, - required: true - } - }, - data() { - return { - dialogVisible: false, - formModel: { - mapId: '', - mapPrdCode: '', - userId: '', - userName: '', - duration: '' - }, - LessonList: [], - mapPrdList: [], - UserList: [], - UserLoading: false - }; - }, - computed: { - form() { - const form = { - labelWidth: '120px', - items: [ - { prop: 'mapId', label: this.$t('system.mapName'), type: 'select', required: true, options: this.LessonList, change: true, onChange: this.mapChange, placeholder: this.$t('rules.mapInput') }, - { prop: 'mapPrdCode', label: this.$t('system.productName'), type: 'select', required: true, options: this.mapPrdList, placeholder: this.$t('rules.productInput') }, - { prop: 'userName', label: this.$t('system.userName'), type: 'complete', required: false, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: this.$t('system.pleaseInputNames') }, - { prop: 'duration', label: this.$t('system.trainingUseTime'), type: 'text', rightWidth: true, required: true, message: 's' } - ] - }; - return form; - }, - rules() { - const crules = { - mapId: [ - { required: true, message: this.$t('rules.mapInput'), trigger: 'change' } - ], - userName: [ - { required: true, message: this.$t('rules.chooseUser'), trigger: 'change' } - ], - mapPrdCode: [ - { required: true, message: this.$t('rules.productInput'), trigger: 'change' } - ], - duration: [ - { required: true, message: this.$t('rules.timeInput'), trigger: 'blur' } - ] - }; - return crules; - }, - title() { - return this.$t('system.createSimulationTitle'); - } - }, - mounted() { - this.initLoadPage(); - }, - methods: { - initLoadPage() { - // 加载发布课程列表 - this.LessonList.length = 0; - this.UserList.length = 0; - const param = { - pageNum: 1, - pageSize: 10 - }; - getPublishMapList(param).then(response => { - const data = response.data.list; - if (data && data.length) { - data.forEach(elem => { - this.LessonList.push({ value: elem.id, label: elem.name, skinCode: elem.skinCode }); - }); - } - }); - }, - // 搜索查询input - async querySearchAsync(queryString, cb) { - // 根据queryString 查询用户 并显示 - const results = []; - if (queryString) { - try { - const params = { - fuzzyParam: queryString - }; - const res = await getDimUserList(params); - const list = res.data; - list.forEach(item => { - const value = { - id: item.id, - value: `${item.nickname}(${item.name})${item.mobile}` - }; - results.push(value); - }); - cb(results); - } catch (error) { - console.error(error); - cb(results); - } - } else { - cb(results); - } - }, - prdSelect(item) { - this.formModel.userId = item.id; - }, - async mapChange(val) { - let skinCode = ''; - this.mapPrdList = []; - this.formModel.mapPrdCode = ''; - if (this.LessonList.length) { - this.LessonList.forEach(item => { - if (item.value == val) { - skinCode = item.skinCode; - } - }); - try { - const res = await getCommodityMapProduct(skinCode); - const data = res.data; - if (data && data.length) { - data.forEach(elem => { - this.mapPrdList.push({ value: elem.code, label: elem.name }); - }); - } - } catch (error) { - console.error(error); - } - } - }, - show(data) { - this.dialogVisible = true; - }, - doSave() { - const self = this; - this.$refs.dataform.validateForm(() => { - self.save(); - }); - }, - save() { - const self = this; - const params = { - mapId: this.formModel.mapId, - mapPrdCode: this.formModel.mapPrdCode, - userId: this.formModel.userId, - duration: parseInt(this.formModel.duration) - }; - if (params.userId) { - postSimulationStats(params).then(response => { - self.$message.success(this.$t('system.addSuccess')); - self.handleClose(); - self.$emit('reloadTable'); - }).catch(error => { - self.$message.error(this.$t('error.addFailed') + error.message); - }); - } else { - this.$message.error(this.$t('rules.chooseUser')); - } - }, - handleClose(done) { - this.formModel = { - mapId: '', - mapPrdCode: '', - userId: '', - userName: '', - duration: '' - }; - this.dialogVisible = false; - } - } + name: 'UsersTrainingAdd', + props: { + type: { + type: String, + required: true + } + }, + data() { + return { + dialogVisible: false, + formModel: { + mapId: '', + mapPrdCode: '', + userId: '', + userName: '', + duration: '' + }, + LessonList: [], + mapPrdList: [], + UserList: [], + UserLoading: false + }; + }, + computed: { + form() { + const form = { + labelWidth: '120px', + items: [ + { prop: 'mapId', label: this.$t('system.mapName'), type: 'select', required: true, options: this.LessonList, change: true, onChange: this.mapChange, placeholder: this.$t('rules.mapInput') }, + { prop: 'mapPrdCode', label: this.$t('system.productName'), type: 'select', required: true, options: this.mapPrdList, placeholder: this.$t('rules.productInput') }, + { prop: 'userName', label: this.$t('system.userName'), type: 'complete', required: false, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: this.$t('system.pleaseInputNames') }, + { prop: 'duration', label: this.$t('system.trainingUseTime'), type: 'text', rightWidth: true, required: true, message: 's' } + ] + }; + return form; + }, + rules() { + const crules = { + mapId: [ + { required: true, message: this.$t('rules.mapInput'), trigger: 'change' } + ], + userName: [ + { required: true, message: this.$t('rules.chooseUser'), trigger: 'change' } + ], + mapPrdCode: [ + { required: true, message: this.$t('rules.productInput'), trigger: 'change' } + ], + duration: [ + { required: true, message: this.$t('rules.timeInput'), trigger: 'blur' } + ] + }; + return crules; + }, + title() { + return this.$t('system.createSimulationTitle'); + } + }, + mounted() { + this.initLoadPage(); + }, + methods: { + initLoadPage() { + // 加载发布课程列表 + this.LessonList.length = 0; + this.UserList.length = 0; + const param = { + pageNum: 1, + pageSize: 10 + }; + getPublishMapList(param).then(response => { + const data = response.data.list; + if (data && data.length) { + data.forEach(elem => { + this.LessonList.push({ value: elem.id, label: elem.name, skinCode: elem.skinCode }); + }); + } + }); + }, + // 搜索查询input + async querySearchAsync(queryString, cb) { + // 根据queryString 查询用户 并显示 + const results = []; + if (queryString) { + try { + const params = { + fuzzyParam: queryString + }; + const res = await getDimUserList(params); + const list = res.data; + list.forEach(item => { + const value = { + id: item.id, + value: `${item.nickname}(${item.name})${item.mobile}` + }; + results.push(value); + }); + cb(results); + } catch (error) { + console.error(error); + cb(results); + } + } else { + cb(results); + } + }, + prdSelect(item) { + this.formModel.userId = item.id; + }, + async mapChange(val) { + this.mapPrdList = []; + this.formModel.mapPrdCode = ''; + try { + const res = await getCommodityMapProduct(val); + const data = res.data; + if (data && data.length) { + data.forEach(elem => { + this.mapPrdList.push({ value: elem.code, label: elem.name }); + }); + } + } catch (error) { + console.error(error); + } + }, + show(data) { + this.dialogVisible = true; + }, + doSave() { + const self = this; + this.$refs.dataform.validateForm(() => { + self.save(); + }); + }, + save() { + const self = this; + const params = { + mapId: this.formModel.mapId, + mapPrdCode: this.formModel.mapPrdCode, + userId: this.formModel.userId, + duration: parseInt(this.formModel.duration) + }; + if (params.userId) { + postSimulationStats(params).then(response => { + self.$message.success(this.$t('system.addSuccess')); + self.handleClose(); + self.$emit('reloadTable'); + }).catch(error => { + self.$message.error(this.$t('error.addFailed') + error.message); + }); + } else { + this.$message.error(this.$t('rules.chooseUser')); + } + }, + handleClose(done) { + this.formModel = { + mapId: '', + mapPrdCode: '', + userId: '', + userName: '', + duration: '' + }; + this.dialogVisible = false; + } + } }; diff --git a/src/views/package/draft/editRule.vue b/src/views/package/draft/editRule.vue index 8db0fc8f2..6742d8a69 100644 --- a/src/views/package/draft/editRule.vue +++ b/src/views/package/draft/editRule.vue @@ -10,7 +10,6 @@ diff --git a/src/views/package/draft/ruleForm.vue b/src/views/package/draft/ruleForm.vue index 2aef00498..c210cdbf2 100644 --- a/src/views/package/draft/ruleForm.vue +++ b/src/views/package/draft/ruleForm.vue @@ -70,7 +70,7 @@