desc: 调整信号机字段显示,调整创建权限逻辑

This commit is contained in:
zyy 2019-09-16 17:31:12 +08:00
parent 7abab1ba28
commit c5c71253df
9 changed files with 308 additions and 73 deletions

View File

@ -109,3 +109,11 @@ export function getGoodsList() {
method: 'get' method: 'get'
}); });
} }
// 通过权限判断有无商品
export function getPermissionGoods(id) {
return request({
url: `/api/goods/list/permissionIds?permissionIds=${id}`,
method: 'get'
});
}

View File

@ -273,6 +273,7 @@ export default {
signalUseType: 'Use the type:', signalUseType: 'Use the type:',
potLampType: 'Light type:', potLampType: 'Light type:',
signalDirectionType: 'The direction of the type:', signalDirectionType: 'The direction of the type:',
signalDirectionTypeX: 'The direction of the type:',
signalPositionType: 'Signal position type:', signalPositionType: 'Signal position type:',
signalOffset: 'The offset:', signalOffset: 'The offset:',
signalPositionX: 'Signal x:', signalPositionX: 'Signal x:',

View File

@ -277,7 +277,8 @@ export default {
lampPositionType: '灯位类型:', lampPositionType: '灯位类型:',
signalUseType: '用途类型:', signalUseType: '用途类型:',
potLampType: '点灯类型:', potLampType: '点灯类型:',
signalDirectionType: '方向类型:', signalDirectionType: '行驶方向:',
signalDirectionTypeX: '显示方向:',
signalPositionType: '信号机位置类型:', signalPositionType: '信号机位置类型:',
signalOffset: '所属link偏移量:', signalOffset: '所属link偏移量:',
signalLinkCode: '所属link', signalLinkCode: '所属link',

View File

@ -33,7 +33,7 @@ class Signal extends Group {
create() { create() {
const model = this.model; const model = this.model;
const style = this.style; const style = this.style;
const drict = this.model.directionType == '01' ? -1 : 1; // 朝向 左:右 const drict = this.model.directionShowType == '01' ? -1 : 1; // 朝向 左:右
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下 const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
// 信号机高柱矮柱 // 信号机高柱矮柱
@ -262,7 +262,7 @@ class Signal extends Group {
} }
} }
} }
/* count 1单灯 2双灯 lightType 01物理点灯 02逻辑点灯*/ /* count 1单灯 2双灯 lightType 01物理点灯 02逻辑点灯*/
openLateral() { openLateral() {
if (this.count == 2 && this.model.lightType == '01') { if (this.count == 2 && this.model.lightType == '01') {
if (this.lamps[0]) { if (this.lamps[0]) {

View File

@ -6,7 +6,7 @@ export function getBaseUrl() {
BASE_API = 'https://test.joylink.club/jlcloud'; BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.4:9000' // 琰培 // BASE_API = 'http://192.168.3.41:9000'; // 王兴杰
} else { } else {
BASE_API = process.env.VUE_APP_BASE_API; BASE_API = process.env.VUE_APP_BASE_API;
} }

View File

@ -49,6 +49,16 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('map.signalDirectionTypeX')" prop="directionShowType">
<el-select v-model="addModel.directionShowType" filterable>
<el-option
v-for="item in SignalDirectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('map.positionType')" prop="positionType"> <el-form-item :label="$t('map.positionType')" prop="positionType">
<el-select v-model="addModel.positionType" filterable> <el-select v-model="addModel.positionType" filterable>
<el-option <el-option
@ -97,6 +107,10 @@ export default {
data() { data() {
return { return {
activeName: 'first', activeName: 'first',
SignalDirectionList: [
{ code: '01', name: '向左' },
{ code: '02', name: '向右' }
],
SignalLeftOrRightList: [], SignalLeftOrRightList: [],
SignalPotLampTypeList: [], SignalPotLampTypeList: [],
SignalLampPostTypeList: [], SignalLampPostTypeList: [],
@ -116,6 +130,7 @@ export default {
lampPostType: '', lampPostType: '',
lampPositionType: '', lampPositionType: '',
potLampType: '01', potLampType: '01',
directionShowType: '',
directionType: '', directionType: '',
positionType: '', positionType: '',
namePosition: { x: 0, y: 0 }, namePosition: { x: 0, y: 0 },
@ -134,6 +149,7 @@ export default {
addModel: { addModel: {
sectionCode: '', sectionCode: '',
directionType: '01', directionType: '01',
directionShowType: '01',
leftOrRight: '0', leftOrRight: '0',
positionType: '01' positionType: '01'
}, },
@ -144,6 +160,9 @@ export default {
directionType: [ directionType: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('rules.directionType'), trigger: 'change' } { required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('rules.directionType'), trigger: 'change' }
], ],
directionShowType: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('rules.directionType'), trigger: 'change' }
],
leftOrRight: [ leftOrRight: [
{ required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('rules.leftOrRight'), trigger: 'change' } { required: true, message: this.$t('map.pleaseSelect') + '' + this.$t('rules.leftOrRight'), trigger: 'change' }
], ],
@ -187,7 +206,7 @@ export default {
] }, ] },
{ prop: 'lampPostType', label: this.$t('map.lampPostType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalLampPostTypeList }, { prop: 'lampPostType', label: this.$t('map.lampPostType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalLampPostTypeList },
{ prop: 'lampPositionType', label: this.$t('map.lampPositionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalLampPositionTypeList }, { prop: 'lampPositionType', label: this.$t('map.lampPositionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalLampPositionTypeList },
{ prop: 'directionType', label: this.$t('map.signalDirectionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalDirectionTypeList }, { prop: 'directionShowType', label: this.$t('map.signalDirectionTypeX'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalDirectionList },
{ prop: 'positionType', label: this.$t('map.signalPositionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalPositionTypeList }, { prop: 'positionType', label: this.$t('map.signalPositionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalPositionTypeList },
{ prop: 'rotate', label: this.$t('map.rotateAngle'), type: 'number', min: -90, max: 90, placeholder: this.$t('tip.angle') }, { prop: 'rotate', label: this.$t('map.rotateAngle'), type: 'number', min: -90, max: 90, placeholder: this.$t('tip.angle') },
{ prop: 'namePosition', label: this.$t('map.signalNamePosition'), type: 'coordinate', width: '140px', children: [ { prop: 'namePosition', label: this.$t('map.signalNamePosition'), type: 'coordinate', width: '140px', children: [
@ -210,6 +229,7 @@ export default {
name: this.$t('map.mapData'), name: this.$t('map.mapData'),
item: [ item: [
{ prop: 'stationCode', label: this.$t('map.equipmentStation'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList }, { prop: 'stationCode', label: this.$t('map.equipmentStation'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.stationList },
{ prop: 'directionType', label: this.$t('map.signalDirectionType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalDirectionTypeList },
{ prop: 'uniqueName', label: this.$t('map.signalUniqueName'), type: 'input' }, { prop: 'uniqueName', label: this.$t('map.signalUniqueName'), type: 'input' },
{ prop: 'useType', label: this.$t('map.signalUseType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalUseTypeList }, { prop: 'useType', label: this.$t('map.signalUseType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalUseTypeList },
{ prop: 'potLampType', label: this.$t('map.potLampType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalPotLampTypeList }, { prop: 'potLampType', label: this.$t('map.potLampType'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.SignalPotLampTypeList },
@ -325,6 +345,7 @@ export default {
uniqueName: uid, uniqueName: uid,
positionType: this.addModel.positionType, positionType: this.addModel.positionType,
directionType: this.addModel.directionType, directionType: this.addModel.directionType,
directionShowType: this.addModel.directionShowType,
nameShow: true, nameShow: true,
namePosition: { x: 0, y: 0 }, namePosition: { x: 0, y: 0 },
buttonShow: true, buttonShow: true,

View File

@ -0,0 +1,151 @@
<template>
<el-dialog
title="新增商品"
:visible.sync="show"
top="20px"
width="600px"
:before-do-close="close"
:close-on-click-modal="false"
>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="create"> </el-button>
</span>
</el-dialog>
</template>
<script>
import { saveCommodityList } from '@/api/management/goods';
export default {
name: 'DictionaryDetailEdit',
components: {
},
data() {
return {
show: false,
TimeStyleList: [],
TimeStyleDict: {},
formModel: {
name: '',
permissionName: '',
permissionId: '',
forever: false,
tryUseTime: 0,
tryUseTimeUnit: '05',
price: 0,
remarks: ''
}
};
},
computed: {
form() {
return {
labelWidth: '135px',
items: [
{ prop: 'name', label: this.$t('orderAuthor.commodityName'), type: 'text', required: false },
{ prop: 'permissionName', label: this.$t('orderAuthor.permission'), type: 'text', required: false, disabled: true, rightWidth: true, buttontip: this.$t('orderAuthor.selectPermission'), buttonClick: this.buttonClick },
{ prop: 'forever', label: this.$t('orderAuthor.whetherTrial'), type: 'radio', required: false, options: this.$ConstSelect.Whether, disabled: false },
{ prop: 'tryUseTimeUnit', label: this.$t('orderAuthor.unitOfTime'), type: 'select', required: false, disabled: false, show: this.isShowForever, options: this.TimeStyleList },
{ prop: 'tryUseTime', label: this.$t('orderAuthor.trialTime'), type: 'number', required: false, disabled: false, show: this.isShowForever, message: `${this.TimeStyleDict[this.formModel.tryUseTimeUnit]}` },
{ prop: 'price', label: this.$t('orderAuthor.price'), type: 'number', required: false, min: 0.01, message: this.$t('global.yuan') },
{ prop: 'remarks', label: this.$t('orderAuthor.describtion'), type: 'textarea', required: false }
]
};
},
rules() {
return {
name: [
{ required: true, message: this.$t('rules.goodsNameInput'), trigger: 'blur' }
],
permissionName: [
{ required: true, message: this.$t('rules.pleaseSelectPermission'), trigger: 'change' }
],
forever: [
{ required: true, message: this.$t('rules.pleaseSelect'), trigger: 'change' }
],
tryUseTime: [
{ required: true, message: this.$t('rules.trialTimeInput'), trigger: 'change' }
],
tryUseTimeUnit: [
{ required: true, message: this.$t('rules.unitOfTimeRadio'), trigger: 'change' }
],
price: [
{ required: true, message: this.$t('rules.totalPriceInput'), trigger: 'change' },
{
validator(rule, value, callback) {
if (Number(value) >= 0) {
if (String(value).split('.')[1] && String(value).split('.')[1].length > 2) {
callback(new Error(this.$t('rules.totalPriceInputError1')));
} else {
callback();
}
} else {
callback(new Error(this.$t('rules.totalPriceInputError2')));
}
},
trigger: 'blur'
}
],
remarks: [
{ required: true, message: this.$t('rules.goodsDescribtionInput'), trigger: 'blur' }
]
};
}
},
mounted() {
this.initLoadPage();
},
methods: {
doShow() {
this.show = true;
},
initLoadPage() {
//
this.TimeStyleDict = {};
this.$Dictionary.timeStyleType().then(list => {
this.convertList(list, this.TimeStyleList, elem => {
return true;
});
list.forEach(elem => {
this.TimeStyleDict[elem.code] = elem.name;
});
});
},
buildModel() {
//
const model = {
name: this.formModel.name,
permissionId: this.formModel.permissionId,
tryUse: this.formModel.forever,
tryUseTime: this.formModel.tryUseTime,
tryUseTimeUnit: this.formModel.tryUseTimeUnit,
price: this.formModel.price,
remarks: this.formModel.remarks
};
return model;
},
create() {
this.$refs.dataform.validateForm(() => {
saveCommodityList(this.buildModel()).then(response => {
this.turnback();
this.$message.success(this.$t('tip.creatingSuccessful'));
}).catch((error) => {
this.$messageBox(this.$t('tip.creatingFailed')+':'+error.message);
});
});
},
close() {
this.show = false;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>

View File

@ -8,15 +8,7 @@
<el-step title="创建订单" icon="el-icon-edit" /> <el-step title="创建订单" icon="el-icon-edit" />
</el-steps> </el-steps>
<div v-show="display == 0"> <div v-show="display == 0">
<el-card class="forms pack-rule"> <permission-form @permissionNext="permissionNext" />
<permission-form />
</el-card>
<div class="draft">
<el-button-group>
<el-button type="primary" @click="packForm">下一步</el-button>
<el-button type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group>
</div>
</div> </div>
<div v-show="display == 1"> <div v-show="display == 1">
<el-card class="forms pack-rule"> <el-card class="forms pack-rule">
@ -84,6 +76,9 @@ export default {
back() { back() {
this.display--; this.display--;
}, },
permissionNext(code) {
this.display = 1;
},
turnback() { turnback() {
this.$router.go(-1); this.$router.go(-1);
}, },

View File

@ -1,77 +1,88 @@
<template> <template>
<div> <div>
<el-form ref="formData" label-width="130px" :model="addModel" size="mini" :rules="rules" class="rule_box"> <el-card class="forms pack-rule">
<el-form-item label="权限类型" prop="type"> <el-form ref="formData" label-width="130px" :model="addModel" size="mini" :rules="rules" class="rule_box">
<el-radio-group v-model="addModel.type"> <el-form-item label="权限类型" prop="type">
<el-radio v-for="item in permissionType" :key="item.value" :label="item.value">{{ item.label }}</el-radio> <el-radio-group v-model="addModel.type">
</el-radio-group> <el-radio v-for="item in permissionType" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
</el-form-item> </el-radio-group>
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.permissionName') + ':'" prop="name"> </el-form-item>
<el-input v-model="addModel.name" size="small" /> <el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.permissionName') + ':'" prop="name">
</el-form-item> <el-input v-model="addModel.name" size="small" />
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.describtion') + ':'" prop="remarks"> </el-form-item>
<el-input <el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.describtion') + ':'" prop="remarks">
v-model="addModel.remarks" <el-input
type="textarea" v-model="addModel.remarks"
:rows="2" type="textarea"
maxlength="60" :rows="2"
show-word-limit maxlength="60"
/> show-word-limit
</el-form-item>
<el-form-item :label="this.$t('orderAuthor.mapName') + ':'">
<el-select v-model="addModel.mapId" :disabled="ruleList.length ? true : false">
<el-option
v-for="item in mapList"
:key="item.value"
:label="item.label"
:value="item.value"
/> />
</el-select> </el-form-item>
</el-form-item> <el-form-item :label="this.$t('orderAuthor.mapName') + ':'">
</el-form> <el-select v-model="addModel.mapId" :disabled="ruleList.length ? true : false">
<div> <el-option
<el-button class="addList" size="small" @click="dialogSelect">{{ $t('orderAuthor.addPermissions') }}</el-button> v-for="item in mapList"
<el-table :key="item.value"
:data="ruleList" :label="item.label"
border :value="item.value"
style="width: 100%" />
:height="addModel.type == '01' ? height-400 : height-500" </el-select>
> </el-form-item>
<el-table-column prop="name" :label="this.$t('orderAuthor.permissionName')" /> </el-form>
<el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')"> <div>
<template slot-scope="scope"> <el-button class="addList" size="small" @click="dialogSelect">{{ $t('orderAuthor.addPermissions') }}</el-button>
{{ computedName(PermissionTypeList, scope.row.type) }} <el-table
</template> :data="ruleList"
</el-table-column> border
<el-table-column :label="this.$t('global.operate')" width="80"> style="width: 100%"
<template slot-scope="scope"> :height="addModel.type == '01' ? height-400 : height-500"
<el-button type="text" size="small" @click="deleteForm(scope.$index, scope.row)">{{ $t('global.delete') }} >
</el-button> <el-table-column prop="name" :label="this.$t('orderAuthor.permissionName')" />
</template> <el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')">
</el-table-column> <template slot-scope="scope">
</el-table> {{ computedName(PermissionTypeList, scope.row.type) }}
</template>
</el-table-column>
<el-table-column :label="this.$t('global.operate')" width="180">
<template slot-scope="scope">
<el-button type="text" size="small" @click="deleteForm(scope.$index, scope.row)">{{ $t('global.delete') }}</el-button>
<el-button v-if="scope.row.flag" type="text" size="small" @click="createGood(scope.$index, scope.row)">创建商品</el-button>
</template>
</el-table-column>
</el-table>
</div>
<choose-permission
ref="choosePermission"
:rule-list="ruleList"
:effective-type-list="EffectiveTypeList"
:permission-type-list="PermissionTypeList"
@addRuleForm="addRuleForm"
@deleteForm="deleteForm"
/>
<create-good ref="createGood" />
</el-card>
<div class="draft">
<el-button-group>
<el-button type="primary" @click="permissionNext">下一步</el-button>
<el-button type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group>
</div> </div>
<choose-permission
ref="choosePermission"
:rule-list="ruleList"
:effective-type-list="EffectiveTypeList"
:permission-type-list="PermissionTypeList"
@addRuleForm="addRuleForm"
@deleteForm="deleteForm"
/>
</div> </div>
</template> </template>
<script> <script>
import ChoosePermission from '../../author/draft/choosePermission'; import ChoosePermission from '../../author/draft/choosePermission';
import CreateGood from './createGood';
import { EventBus } from '@/scripts/event-bus'; import { EventBus } from '@/scripts/event-bus';
import { listPublishMap } from '@/api/jmap/map'; import { listPublishMap } from '@/api/jmap/map';
// import { getPermissionList } from '@/api/management/author'; import { getPermissionGoods } from '@/api/management/goods';
export default { export default {
name: 'PermissionForm', name: 'PermissionForm',
components: { components: {
ChoosePermission ChoosePermission,
CreateGood
}, },
data() { data() {
return { return {
@ -83,6 +94,7 @@ export default {
{value: '02', label: '权限包'} {value: '02', label: '权限包'}
], ],
mapList: [], mapList: [],
goodsList: [],
addModel: { addModel: {
type: '01', type: '01',
name: '', name: '',
@ -111,6 +123,11 @@ export default {
this.EffectiveTypeList = list.map(elem => { return { value: elem.code, label: elem.name }; }); this.EffectiveTypeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
}); });
this.PermissionTypeList = [];
this.$Dictionary.permissionType().then(list => {
this.PermissionTypeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
});
try { try {
// //
this.mapList = []; this.mapList = [];
@ -139,6 +156,9 @@ export default {
} }
EventBus.$emit('reloadTable', { index: index, list: row }); EventBus.$emit('reloadTable', { index: index, list: row });
}, },
createGood(index, row) {
this.$refs.createGood.doShow();
},
addRuleForm(index, row) { addRuleForm(index, row) {
row['isPut'] = true; row['isPut'] = true;
this.ruleList.push(row); this.ruleList.push(row);
@ -150,12 +170,50 @@ export default {
} else { } else {
this.$messageBox(this.$t('rules.mapInput')); this.$messageBox(this.$t('rules.mapInput'));
} }
},
async permissionNext() {
if (this.ruleList.length) {
const arr = this.ruleList.map(item => {
return item.id;
});
const res = await getPermissionGoods(arr.join(','));
if (res.code == 200) {
this.goodsList = res.data;
if (this.goodsList.length == this.ruleList.length) {
this.$emit('permissionNext', this.addModel.type);
} else {
this.goodsList.forEach(nor => {
this.ruleList.forEach(ele => {
if (nor.permissionId == ele.id) {
ele.createGood = true;
}
});
});
this.ruleList.forEach(item => {
item.flag = true;
if (item.createGood) {
item.flag = false;
}
});
this.$messageBox('基础权限没有对应商品类型, 请创建商品');
}
}
} else {
this.$messageBox('请添加权限');
}
},
turnback() {
this.$router.go(-1);
} }
} }
}; };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.pack-rule { .pack-rule {
width: 800px;
margin: 0 auto;
margin-top: 12px;
padding: 40px;
.addList { .addList {
float: right; float: right;
font-size: 14px; font-size: 14px;