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'
});
}
// 通过权限判断有无商品
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:',
potLampType: 'Light type:',
signalDirectionType: 'The direction of the type:',
signalDirectionTypeX: 'The direction of the type:',
signalPositionType: 'Signal position type:',
signalOffset: 'The offset:',
signalPositionX: 'Signal x:',

View File

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

View File

@ -33,7 +33,7 @@ class Signal extends Group {
create() {
const model = this.model;
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; // 位置 上:下
// 信号机高柱矮柱
@ -262,7 +262,7 @@ class Signal extends Group {
}
}
}
/* count 1单灯 2双灯 lightType 01物理点灯 02逻辑点灯*/
/* count 1单灯 2双灯 lightType 01物理点灯 02逻辑点灯*/
openLateral() {
if (this.count == 2 && this.model.lightType == '01') {
if (this.lamps[0]) {

View File

@ -6,7 +6,7 @@ export function getBaseUrl() {
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5: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 {
BASE_API = process.env.VUE_APP_BASE_API;
}

View File

@ -49,6 +49,16 @@
/>
</el-select>
</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-select v-model="addModel.positionType" filterable>
<el-option
@ -97,6 +107,10 @@ export default {
data() {
return {
activeName: 'first',
SignalDirectionList: [
{ code: '01', name: '向左' },
{ code: '02', name: '向右' }
],
SignalLeftOrRightList: [],
SignalPotLampTypeList: [],
SignalLampPostTypeList: [],
@ -116,6 +130,7 @@ export default {
lampPostType: '',
lampPositionType: '',
potLampType: '01',
directionShowType: '',
directionType: '',
positionType: '',
namePosition: { x: 0, y: 0 },
@ -134,6 +149,7 @@ export default {
addModel: {
sectionCode: '',
directionType: '01',
directionShowType: '01',
leftOrRight: '0',
positionType: '01'
},
@ -144,6 +160,9 @@ export default {
directionType: [
{ 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: [
{ 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: '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: '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: [
@ -210,6 +229,7 @@ export default {
name: this.$t('map.mapData'),
item: [
{ 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: '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 },
@ -325,6 +345,7 @@ export default {
uniqueName: uid,
positionType: this.addModel.positionType,
directionType: this.addModel.directionType,
directionShowType: this.addModel.directionShowType,
nameShow: true,
namePosition: { x: 0, y: 0 },
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-steps>
<div v-show="display == 0">
<el-card class="forms pack-rule">
<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>
<permission-form @permissionNext="permissionNext" />
</div>
<div v-show="display == 1">
<el-card class="forms pack-rule">
@ -84,6 +76,9 @@ export default {
back() {
this.display--;
},
permissionNext(code) {
this.display = 1;
},
turnback() {
this.$router.go(-1);
},

View File

@ -1,77 +1,88 @@
<template>
<div>
<el-form ref="formData" label-width="130px" :model="addModel" size="mini" :rules="rules" class="rule_box">
<el-form-item label="权限类型" prop="type">
<el-radio-group v-model="addModel.type">
<el-radio v-for="item in permissionType" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.permissionName') + ':'" prop="name">
<el-input v-model="addModel.name" size="small" />
</el-form-item>
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.describtion') + ':'" prop="remarks">
<el-input
v-model="addModel.remarks"
type="textarea"
:rows="2"
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-card class="forms pack-rule">
<el-form ref="formData" label-width="130px" :model="addModel" size="mini" :rules="rules" class="rule_box">
<el-form-item label="权限类型" prop="type">
<el-radio-group v-model="addModel.type">
<el-radio v-for="item in permissionType" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.permissionName') + ':'" prop="name">
<el-input v-model="addModel.name" size="small" />
</el-form-item>
<el-form-item v-show="addModel.type == '02'" :label="this.$t('orderAuthor.describtion') + ':'" prop="remarks">
<el-input
v-model="addModel.remarks"
type="textarea"
:rows="2"
maxlength="60"
show-word-limit
/>
</el-select>
</el-form-item>
</el-form>
<div>
<el-button class="addList" size="small" @click="dialogSelect">{{ $t('orderAuthor.addPermissions') }}</el-button>
<el-table
:data="ruleList"
border
style="width: 100%"
:height="addModel.type == '01' ? height-400 : height-500"
>
<el-table-column prop="name" :label="this.$t('orderAuthor.permissionName')" />
<el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')">
<template slot-scope="scope">
{{ computedName(PermissionTypeList, scope.row.type) }}
</template>
</el-table-column>
<el-table-column :label="this.$t('global.operate')" width="80">
<template slot-scope="scope">
<el-button type="text" size="small" @click="deleteForm(scope.$index, scope.row)">{{ $t('global.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
</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>
<div>
<el-button class="addList" size="small" @click="dialogSelect">{{ $t('orderAuthor.addPermissions') }}</el-button>
<el-table
:data="ruleList"
border
style="width: 100%"
:height="addModel.type == '01' ? height-400 : height-500"
>
<el-table-column prop="name" :label="this.$t('orderAuthor.permissionName')" />
<el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')">
<template slot-scope="scope">
{{ 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>
<choose-permission
ref="choosePermission"
:rule-list="ruleList"
:effective-type-list="EffectiveTypeList"
:permission-type-list="PermissionTypeList"
@addRuleForm="addRuleForm"
@deleteForm="deleteForm"
/>
</div>
</template>
<script>
import ChoosePermission from '../../author/draft/choosePermission';
import CreateGood from './createGood';
import { EventBus } from '@/scripts/event-bus';
import { listPublishMap } from '@/api/jmap/map';
// import { getPermissionList } from '@/api/management/author';
import { getPermissionGoods } from '@/api/management/goods';
export default {
name: 'PermissionForm',
components: {
ChoosePermission
ChoosePermission,
CreateGood
},
data() {
return {
@ -83,6 +94,7 @@ export default {
{value: '02', label: '权限包'}
],
mapList: [],
goodsList: [],
addModel: {
type: '01',
name: '',
@ -111,6 +123,11 @@ export default {
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 {
//
this.mapList = [];
@ -139,6 +156,9 @@ export default {
}
EventBus.$emit('reloadTable', { index: index, list: row });
},
createGood(index, row) {
this.$refs.createGood.doShow();
},
addRuleForm(index, row) {
row['isPut'] = true;
this.ruleList.push(row);
@ -150,12 +170,50 @@ export default {
} else {
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>
<style rel="stylesheet/scss" lang="scss" scoped>
.pack-rule {
width: 800px;
margin: 0 auto;
margin-top: 12px;
padding: 40px;
.addList {
float: right;
font-size: 14px;