Commit 2bc6bd51 by 胡悦

1.0.1需求

1 parent 6908c246
...@@ -21,4 +21,8 @@ function save(data, baseURl) { ...@@ -21,4 +21,8 @@ function save(data, baseURl) {
} }
}) })
} }
export { getList, putOnOff, checkShopProductId, save } // 产品详情
function productDetail(params) {
return GlAxios.get(`${path}getById`, { params })
}
export { getList, putOnOff, checkShopProductId, save, productDetail }
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
type="text" type="text"
@click="handleProOnOff(scope.scope)" @click="handleProOnOff(scope.scope)"
>{{scope.scope.status ? '下架' : '上架'}}</el-button> >{{scope.scope.status ? '下架' : '上架'}}</el-button>
<!-- <el-button <el-button
type="text" type="text"
@click="handleProEdit(scope.scope)" @click="handleProEdit(scope.scope)"
>指令集</el-button> --> >编辑</el-button>
</span> </span>
</d2-table> </d2-table>
<glsx-dialog <glsx-dialog
...@@ -121,7 +121,7 @@ import _ from 'lodash' ...@@ -121,7 +121,7 @@ import _ from 'lodash'
import axios from 'axios' import axios from 'axios'
import sign from '@/api/sign' import sign from '@/api/sign'
import qs from 'qs' import qs from 'qs'
import { getList, putOnOff, checkShopProductId, save } from '@/api/product' import { getList, putOnOff, checkShopProductId, save, productDetail } from '@/api/product'
import { getDict, batchSaveFile } from '@/api/common' import { getDict, batchSaveFile } from '@/api/common'
import { getTypeList } from '@/api/productType' import { getTypeList } from '@/api/productType'
...@@ -287,6 +287,16 @@ export default { ...@@ -287,6 +287,16 @@ export default {
this.$refs.productRuleForm.resetFields() this.$refs.productRuleForm.resetFields()
} }
}, },
handleProEdit(row) {
productDetail({ id: row.id }).then(res => {
this.change(res.platformKey, 'platformKey')
const arr = ['id', 'productName', 'icon', 'iconUrl', 'typeId', 'shopProductId', 'platformKey', 'platformProductId', 'networkKey']
arr.forEach(item => {
this.$set(this.productRuleForm, item, res[item])
})
})
this.switchDialog()
},
handleSubmit() { handleSubmit() {
console.log(this.productRuleForm) console.log(this.productRuleForm)
this.$refs.productRuleForm.validate((valid) => { this.$refs.productRuleForm.validate((valid) => {
...@@ -296,7 +306,6 @@ export default { ...@@ -296,7 +306,6 @@ export default {
delete params.iconUrl delete params.iconUrl
console.log(params) console.log(params)
save(params, this.baseURL).then(res => { save(params, this.baseURL).then(res => {
console.log(res)
if (res) { if (res) {
this.$message({ this.$message({
type: 'success', type: 'success',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<el-dialog <el-dialog
:title="params.basicForm.id ? '编辑场景' : '添加场景'" :title="params.basicForm.id ? '编辑场景' : '添加场景'"
:visible.sync="visible" :visible.sync="visible"
:close-on-click-modal="visible" :close-on-click-modal="false"
:show-close="false" :show-close="false"
> >
<el-steps <el-steps
...@@ -86,6 +86,37 @@ ...@@ -86,6 +86,37 @@
> >
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="场景缩略图"
prop="pagePic"
>
<el-image
v-show="params.basicForm.pagePicUrl"
style="width: 100px; height: 100px"
:src="params.basicForm.pagePicUrl"
>
<div
slot="error"
class="image-slot"
>
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
<el-button
class="import-btn"
style="display: block;"
type="primary"
>上传缩略图
<input
type="file"
id="fileUpload"
class="import-input"
multiple="3"
accept="image/png, image/jpeg, image/jpg"
@change="uploadImg($event, 'pagePic')"
/>
</el-button>
</el-form-item>
<el-form-item
label="场景背景图" label="场景背景图"
prop="backPic" prop="backPic"
> >
...@@ -105,14 +136,14 @@ ...@@ -105,14 +136,14 @@
class="import-btn" class="import-btn"
style="display: block;" style="display: block;"
type="primary" type="primary"
>上传图片 >上传背景图
<input <input
type="file" type="file"
id="fileUpload" id="fileUpload"
class="import-input" class="import-input"
multiple="3" multiple="3"
accept="image/png, image/jpeg, image/jpg" accept="image/png, image/jpeg, image/jpg"
@change="uploadImg($event)" @change="uploadImg($event, 'backPic')"
/> />
</el-button> </el-button>
</el-form-item> </el-form-item>
...@@ -193,6 +224,28 @@ ...@@ -193,6 +224,28 @@
<el-form-item <el-form-item
v-if="item.paramKey == 'scene_condition_time'" v-if="item.paramKey == 'scene_condition_time'"
class="inline" class="inline"
:prop="'conditionList.'+index+'.paramValue.select'"
:rules="{
required: true, message: '该选项不能为空', trigger: 'change'
}"
>
<el-select
v-model="item.paramValue.select"
placeholder="请选择"
@change="firstChange(item.paramValue.select, index, 'condition', 'time')"
>
<el-option
v-for="i in timeList"
:key="i.label"
:label="i.label"
:value="i.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
v-if="item.paramValue.select"
class="inline"
:prop="'conditionList.'+index+'.paramValue.date'" :prop="'conditionList.'+index+'.paramValue.date'"
:rules="{ :rules="{
required: true, message: '时间不能为空', trigger: 'change' required: true, message: '时间不能为空', trigger: 'change'
...@@ -484,6 +537,7 @@ export default { ...@@ -484,6 +537,7 @@ export default {
sceneName: [{ required: true, message: '请输入场景名称', trigger: 'blur' }], sceneName: [{ required: true, message: '请输入场景名称', trigger: 'blur' }],
typeKey: [{ required: true, message: '请选择场景类型', trigger: 'blur' }], typeKey: [{ required: true, message: '请选择场景类型', trigger: 'blur' }],
icon: [{ required: true, message: '请选择场景图标', trigger: 'blur' }], icon: [{ required: true, message: '请选择场景图标', trigger: 'blur' }],
pagePic: [{ required: true, message: '请上传场景缩略图', trigger: 'change' }],
backPic: [{ required: true, message: '请上传场景背景图', trigger: 'change' }] backPic: [{ required: true, message: '请上传场景背景图', trigger: 'change' }]
}, },
iconList: [], iconList: [],
...@@ -494,6 +548,11 @@ export default { ...@@ -494,6 +548,11 @@ export default {
condition: [{ required: true, message: '请选择场景触发条件', trigger: 'change' }], condition: [{ required: true, message: '请选择场景触发条件', trigger: 'change' }],
executeCycle: [{ required: true, message: '请选择场景执行周期', trigger: 'change' }] executeCycle: [{ required: true, message: '请选择场景执行周期', trigger: 'change' }]
}, },
timeList: [
{ label: '手动设置', value: 1 },
{ label: '时间大于', value: 2 },
{ label: '时间小于', value: 3 }
],
cycleList: [ cycleList: [
{ label: '每天', value: 1 }, { label: '每天', value: 1 },
{ label: '工作日', value: 2 }, { label: '工作日', value: 2 },
...@@ -529,7 +588,6 @@ export default { ...@@ -529,7 +588,6 @@ export default {
created() { created() {
// 场景类型 // 场景类型
getDict({ dictType: 'scene_classification' }).then(res => (this.typeList = res)) getDict({ dictType: 'scene_classification' }).then(res => (this.typeList = res))
// 场景触发条件 // 场景触发条件
getDict({ dictType: 'scene_condition' }).then(res => (this.sceneCondition = res.slice(1))) getDict({ dictType: 'scene_condition' }).then(res => (this.sceneCondition = res.slice(1)))
getConditionList({}).then(res => (this.deviceConditionList = res)) getConditionList({}).then(res => (this.deviceConditionList = res))
...@@ -539,9 +597,7 @@ export default { ...@@ -539,9 +597,7 @@ export default {
}, },
watch: { watch: {
visible(val) { visible(val) {
console.log(val)
if (val && this.params.basicForm.id) { if (val && this.params.basicForm.id) {
console.log(this.params)
const conditionList = this.params.conditionList const conditionList = this.params.conditionList
const contentList = this.params.contentList const contentList = this.params.contentList
conditionList.forEach(item => { conditionList.forEach(item => {
...@@ -608,7 +664,7 @@ export default { ...@@ -608,7 +664,7 @@ export default {
}) })
}, },
handleParams() { handleParams() {
const basicForm = this.clearObject(this.params.basicForm, ['backPicUrl', 'iconUrl']) const basicForm = this.clearObject(this.params.basicForm, ['backPicUrl', 'pagePicUrl', 'iconUrl'])
const conditionList = _.cloneDeep(this.params.conditionList).map(item => this.clearObject(item, ['list', 'noValue', 'key'])) const conditionList = _.cloneDeep(this.params.conditionList).map(item => this.clearObject(item, ['list', 'noValue', 'key']))
const contentList = _.cloneDeep(this.params.contentList).map(item => this.clearObject(item, ['list', 'lastList', 'key', 'orderType'])) const contentList = _.cloneDeep(this.params.contentList).map(item => this.clearObject(item, ['list', 'lastList', 'key', 'orderType']))
const templateList = conditionList.concat(contentList) const templateList = conditionList.concat(contentList)
...@@ -649,7 +705,7 @@ export default { ...@@ -649,7 +705,7 @@ export default {
this.params.basicForm.iconUrl = this.iconList.find(item => item.id == val).url this.params.basicForm.iconUrl = this.iconList.find(item => item.id == val).url
}, },
// 上传图片 // 上传图片
uploadImg(e) { uploadImg(e, name) {
// // 转码base64 // // 转码base64
const reader = new FileReader() const reader = new FileReader()
reader.readAsDataURL(e.target.files[0]) reader.readAsDataURL(e.target.files[0])
...@@ -664,10 +720,10 @@ export default { ...@@ -664,10 +720,10 @@ export default {
this.request({ this.request({
fileName: e.target.files[0].name.split('.')[0], fileName: e.target.files[0].name.split('.')[0],
file: fileInfo file: fileInfo
}, 'glsx.accounts.biz.common.pictureUpload', iconObj) }, 'glsx.accounts.biz.common.pictureUpload', iconObj, name)
} }
}, },
request(params = {}, method, targetObj, noSignAttr = ['file']) { request(params = {}, method, targetObj, name, noSignAttr = ['file']) {
const fileUploadURL = this.$get_session_common_config().axios.fileUploadURL const fileUploadURL = this.$get_session_common_config().axios.fileUploadURL
params.source = 'glsx-oss-carowner' params.source = 'glsx-oss-carowner'
params.app_key = '48e5e13229b82c1b4e6e8c96151f0637' params.app_key = '48e5e13229b82c1b4e6e8c96151f0637'
...@@ -678,12 +734,12 @@ export default { ...@@ -678,12 +734,12 @@ export default {
const data = sign(params, noSignAttr) const data = sign(params, noSignAttr)
axios.post(`${fileUploadURL}/router?method=${method}`, qs.stringify(data)).then(res => { axios.post(`${fileUploadURL}/router?method=${method}`, qs.stringify(data)).then(res => {
if (res.status === 200) { if (res.status === 200) {
this.$set(this.params.basicForm, 'backPicUrl', res.data.data) this.$set(this.params.basicForm, `${name}Url`, res.data.data)
targetObj.url = res.data.data targetObj.url = res.data.data
} }
const fileData = new Array(targetObj) const fileData = new Array(targetObj)
return batchSaveFile(fileData, this.baseURL) return batchSaveFile(fileData, this.baseURL)
}).then(r => (this.params.basicForm.backPic = r[0].id)) }).then(r => (this.params.basicForm[name] = r[0].id))
}, },
switchDialog() { switchDialog() {
this.$emit('hideDialog') this.$emit('hideDialog')
...@@ -714,17 +770,19 @@ export default { ...@@ -714,17 +770,19 @@ export default {
else if (name === 'content') this.params.contentList[index].paramValue = _.cloneDeep(this.defalutContentObj.paramValue) else if (name === 'content') this.params.contentList[index].paramValue = _.cloneDeep(this.defalutContentObj.paramValue)
}, },
// 设备状态第二个下拉框 // 设备状态第二个下拉框
firstChange(e, index, name) { firstChange(e, index, name, type) {
if (name === 'condition') { if (name === 'condition') {
const arr = this.deviceConditionList.find(item => item.id === e).conditionList if (type !== 'time') {
const value = this.params.conditionList[index].paramValue const arr = this.deviceConditionList.find(item => item.id === e).conditionList
value.list = arr const value = this.params.conditionList[index].paramValue
const valueArr = ['order', 'orderCondition', 'orderId', 'orderVal', 'value'] value.list = arr
valueArr.forEach(item => { const valueArr = ['order', 'orderCondition', 'orderId', 'orderVal', 'value']
if (value[item]) value[item] = '' valueArr.forEach(item => {
}) if (value[item]) value[item] = ''
if (value.id) this.$set(value, 'id', null) })
if (value.noValue) value.noValue = false if (value.id) this.$set(value, 'id', null)
if (value.noValue) value.noValue = false
}
} else { } else {
const arr = this.deviceContentList.find(item => item.id === e).contentList const arr = this.deviceContentList.find(item => item.id === e).contentList
const value = this.params.contentList[index].paramValue const value = this.params.contentList[index].paramValue
...@@ -737,7 +795,6 @@ export default { ...@@ -737,7 +795,6 @@ export default {
}, },
// 设备状态三个下拉框 // 设备状态三个下拉框
secondChange(e, index, name) { secondChange(e, index, name) {
console.log(e)
if (name === 'condition') { if (name === 'condition') {
const obj = this.params.conditionList[index].paramValue.list.find(item => item.id === e) const obj = this.params.conditionList[index].paramValue.list.find(item => item.id === e)
const paramValue = this.params.conditionList[index].paramValue const paramValue = this.params.conditionList[index].paramValue
...@@ -750,6 +807,7 @@ export default { ...@@ -750,6 +807,7 @@ export default {
const obj = this.params.contentList[index].paramValue.list.find(item => item.id === e) const obj = this.params.contentList[index].paramValue.list.find(item => item.id === e)
const paramValue = this.params.contentList[index].paramValue const paramValue = this.params.contentList[index].paramValue
paramValue.valType = obj.orderValueType paramValue.valType = obj.orderValueType
paramValue.order = obj.orderCode
paramValue.orderType = obj.orderType paramValue.orderType = obj.orderType
const id = obj.id const id = obj.id
if (obj.orderType == 2) { if (obj.orderType == 2) {
......
...@@ -87,6 +87,8 @@ export default { ...@@ -87,6 +87,8 @@ export default {
id: '', id: '',
backPic: '', backPic: '',
backPicUrl: '', backPicUrl: '',
pagePic: '',
pagePicUrl: '',
description: '', description: '',
icon: '', icon: '',
iconUrl: '', iconUrl: '',
...@@ -105,6 +107,8 @@ export default { ...@@ -105,6 +107,8 @@ export default {
id: '', id: '',
backPic: '', backPic: '',
backPicUrl: '', backPicUrl: '',
pagePic: '',
pagePicUrl: '',
description: '', description: '',
icon: '', icon: '',
iconUrl: '', iconUrl: '',
...@@ -164,6 +168,7 @@ export default { ...@@ -164,6 +168,7 @@ export default {
const { scenarioParams } = this const { scenarioParams } = this
for (const i in scenarioParams.basicForm) { for (const i in scenarioParams.basicForm) {
if (i === 'backPicUrl') this.$set(scenarioParams, 'backPicUrl', res[i]) if (i === 'backPicUrl') this.$set(scenarioParams, 'backPicUrl', res[i])
if (i === 'pagePicUrl') this.$set(scenarioParams, 'pagePicUrl', res[i])
scenarioParams.basicForm[i] = res[i] scenarioParams.basicForm[i] = res[i]
} }
for (const i in scenarioParams.scenarioRuleForm) { for (const i in scenarioParams.scenarioRuleForm) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!