Commit b3b79cbc by 胡悦

新增场景、编辑场景

1 parent 5acbd295
......@@ -3,7 +3,7 @@ import axios from './axios'
const path = '/smartAdmin/productType/'
// 产品类型列表
function getList(params) {
function getTypeList(params) {
return GlAxios.get(`${path}getPageList`, { params })
}
......@@ -21,4 +21,4 @@ function save(data, baseURl) {
})
}
export { getList, getShopTagList, save }
export { getTypeList, getShopTagList, save }
......@@ -74,7 +74,7 @@
<el-option
v-for="i in item.options"
:key="i.value"
:label="i.dictValue || i.productName"
:label="i.dictValue || i.typeName"
:value="i.dictKey || i.id"
>
</el-option>
......@@ -115,6 +115,8 @@ import sign from '@/api/sign'
import qs from 'qs'
import { getList, putOnOff, checkShopProductId, save } from '@/api/product'
import { getDict, batchSaveFile } from '@/api/common'
import { getTypeList } from '@/api/productType'
export default {
data() {
const validatePass = (rule, value, callback) => {
......@@ -240,7 +242,7 @@ export default {
}
},
created() {
getList({}).then(res => {
getTypeList({}).then(res => {
for (let i = this.productFormList.length; i > 0; i--) {
if (this.productFormList[i] && this.productFormList[i].prop === 'typeId') return (this.productFormList[i].options = res.list)
}
......
......@@ -97,7 +97,7 @@
<script>
import { getDict } from '@/api/common'
import { getList, getShopTagList, save } from '@/api/productType'
import { getTypeList, getShopTagList, save } from '@/api/productType'
export default {
data() {
return {
......@@ -133,7 +133,7 @@ export default {
}
]
},
prodectTypeApi: getList,
prodectTypeApi: getTypeList,
visible: false,
ruleForm: {},
rules: {
......
......@@ -2,7 +2,7 @@
<div>
<el-button
type="primary"
@click="hideDialog"
@click="create"
>添加场景</el-button>
<d2-table
ref="scenarioTable"
......@@ -35,6 +35,7 @@
</template>
<script>
import _ from 'lodash'
import { getList, updateStatus, getById } from '@/api/scenario'
import { getDict } from '@/api/common'
import AddScenario from './addScenario'
......@@ -81,20 +82,101 @@ export default {
getListApi: getList,
typeList: [],
visible: false,
scenarioParams: {}
scenarioParams: {
basicForm: {
id: '',
backPic: '',
backPicUrl: '',
description: '',
icon: '',
iconUrl: '',
sceneName: '',
typeKey: ''
},
scenarioRuleForm: {
conditionRule: '',
executeCycle: ''
},
conditionList: [],
contentList: []
},
defalutScenarioParams: {
basicForm: {
id: '',
backPic: '',
backPicUrl: '',
description: '',
icon: '',
iconUrl: '',
sceneName: '',
typeKey: ''
},
scenarioRuleForm: {
conditionRule: '',
executeCycle: ''
},
conditionList: [
{
key: parseInt(Math.random() * 1000),
type: 1,
paramKey: '',
paramValue: {
date: '',
select: '',
order: '',
value: ''
}
}
],
contentList: [
{
key: parseInt(Math.random() * 1000),
type: 2,
paramKey: '',
paramValue: {
msg: '',
select: '',
order: '',
orderVal: ''
}
}
]
}
}
},
created() {
getDict({ dictType: 'scene_classification' }).then(res => (this.typeList = res))
},
methods: {
hideDialog() {
hideDialog(t) {
this.visible = !this.visible
if (t) this.$refs.scenarioTable.refreshTable()
},
create() {
this.scenarioParams = _.cloneDeep(this.defalutScenarioParams)
this.hideDialog()
},
handleEdit(scope) {
getById({ id: scope.id }, this.baseURL).then(res => {
console.log(res)
this.scenarioParams = res
const { scenarioParams } = this
for (const i in scenarioParams.basicForm) {
scenarioParams.basicForm[i] = res[i]
}
for (const i in scenarioParams.scenarioRuleForm) {
if (i === 'conditionRule') scenarioParams.scenarioRuleForm[i] = '' + res[i]
else scenarioParams.scenarioRuleForm[i] = res[i]
}
scenarioParams.basicForm.id = res.id
const templateList = res.templateList
scenarioParams.conditionList = []
scenarioParams.contentList = []
if (templateList.length !== 0) {
templateList.forEach(item => {
item.paramValue = JSON.parse(item.paramValue)
if (item.type === 1) scenarioParams.conditionList.push(item)
else if (item.type === 2) scenarioParams.contentList.push(item)
})
}
this.hideDialog()
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!