自定义策略
This commit is contained in:
33
acs/nladmin-ui/src/api/acs/device/customPolicy.js
Normal file
33
acs/nladmin-ui/src/api/acs/device/customPolicy.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/customPolicy',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/customPolicy/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/customPolicy',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function updateOn(id, is_on) {
|
||||
console.log(is_on)
|
||||
return request({
|
||||
url: '/api/customPolicy/updateOn?id=' + id + '&is_on=' + is_on,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export default { add, edit, del, updateOn }
|
||||
22
acs/nladmin-ui/src/api/acs/device/customPolicyType.js
Normal file
22
acs/nladmin-ui/src/api/acs/device/customPolicyType.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import request from '@/utils/request'
|
||||
export function updateConfig(plans, deviceCode, id) {
|
||||
const data = {
|
||||
plans,
|
||||
deviceCode,
|
||||
id
|
||||
}
|
||||
return request({
|
||||
url: '/api/customPolicy/plantAdd',
|
||||
data,
|
||||
method: 'post'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export function selectById(id) {
|
||||
return request({
|
||||
url: '/api/customPolicy/plantList?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -157,6 +157,13 @@ export function excelImport(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function selectListByType() {
|
||||
return request({
|
||||
url: 'api/device//type/stacker',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, selectDeviceList, selectDeviceListByRegion, callAgv, responseAgv, selectDeviceDevicerInfo, autoCreateTask,
|
||||
changeDeviceStatus, cleanTask, queryStorageExtra, selectConDeviceList, saveBarcode, selectDeviceListOne, selectDeviceListTwo, selectDeviceListThree,
|
||||
addMaterial, cleanMaterial, reload, excelImport }
|
||||
addMaterial, cleanMaterial, reload, excelImport, selectListByType }
|
||||
|
||||
@@ -21,6 +21,11 @@ export const constantRouterMap = [
|
||||
component: (resolve) => require(['@/views/features/401'], resolve),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/device/customPolicy/task',
|
||||
component: (resolve) => require(['@/views/acs/device/customPolicy/task/index'], resolve),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/redirect',
|
||||
component: Layout,
|
||||
|
||||
132
acs/nladmin-ui/src/views/acs/device/customPolicy/index.vue
Normal file
132
acs/nladmin-ui/src/views/acs/device/customPolicy/index.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
||||
<el-form-item label="设备号" prop="key_code">
|
||||
<el-select
|
||||
v-model="form.key_code"
|
||||
style="width: 370px;"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="策略名称" prop="key_code">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="id" label="id" />
|
||||
<el-table-column prop="key_code" label="设备号" />
|
||||
<el-table-column prop="create_user" label="创建用户名" />
|
||||
<el-table-column prop="update_user" label="更新用户名" />
|
||||
<el-table-column prop="name" label="策略名称" />
|
||||
<el-table-column prop="create_time" label="创建时间" />
|
||||
<el-table-column prop="update_time" label="更新时间" />
|
||||
<el-table-column prop="is_on" label="是否启用">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_on"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
@change="updateIsOn(scope.row.id,scope.row.is_on)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-permission="['admin','customPolicy:del']" label="操作" width="150px" align="center">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
<el-button slot="right" size="mini" style="margin-left: -1px;margin-right: 2px" type="text">
|
||||
<router-link :to="'/device/customPolicy/task?key_code='+ scope.row.key_code +'&id='+scope.row.id">
|
||||
定义策略
|
||||
</router-link>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudCustomPolicy from '@/api/acs/device/customPolicy'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
const defaultForm = { id: null, create_time: null, update_time: null, key_code: null }
|
||||
export default {
|
||||
name: 'CustomPolicy',
|
||||
// eslint-disable-next-line vue/no-unused-components
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '自定义策略', url: 'api/customPolicy', idField: 'id', sort: 'id,desc', crudMethod: { ...crudCustomPolicy }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
add: ['admin', 'customPolicy:add'],
|
||||
edit: ['admin', 'customPolicy:edit'],
|
||||
del: ['admin', 'customPolicy:del']
|
||||
},
|
||||
deviceList: [],
|
||||
rules: {
|
||||
key_code: [
|
||||
{ required: true, message: '设备号不能为空', trigger: 'blur' }
|
||||
]
|
||||
}}
|
||||
},
|
||||
created() {
|
||||
deviceCrud.selectListByType().then(data => {
|
||||
this.deviceList = data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
updateIsOn(id, is_on) {
|
||||
crudCustomPolicy.updateOn(id, is_on).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
203
acs/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue
Normal file
203
acs/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue
Normal file
@@ -0,0 +1,203 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备名称:{{ key_code }} </span>
|
||||
</div>
|
||||
<div class="crud-opts2" style="margin-bottom: 5px;">
|
||||
<span class="crud-opts-right2">
|
||||
<!--左侧插槽-->
|
||||
<slot name="left" />
|
||||
<el-button
|
||||
slot="left"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="insertdtl()"
|
||||
>
|
||||
新增一行
|
||||
</el-button>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class="app-container">
|
||||
<el-table :data="modeform.plans" border fit highlight-current-row style="width: 100%;" class="tb-edit">
|
||||
<el-table-column label="起始设备" prop="from" width="180">
|
||||
<template scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.from"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="目标设备" prop="to" width="180">
|
||||
<template scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.to"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceList"
|
||||
:key="item.device_code"
|
||||
:label="item.device_name"
|
||||
:value="item.device_code"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="quantity" width="180">
|
||||
<template scope="scope">
|
||||
<el-input-number v-model="scope.row.quantity" value="0" :min="0" size="mini" />
|
||||
<span v-show="scope.row.edit">{{ scope.row.quantity }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="任务类型" prop="type" width="180">
|
||||
<template scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.type"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in requestMethodList"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="操作" width="170">
|
||||
<template scope="scope">
|
||||
<el-button
|
||||
type="danger"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click.native.prevent="deleteRow(scope.$index, modeform.plans)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="back"
|
||||
>取消
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { updateConfig, selectById } from '@/api/acs/device/customPolicyType'
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
import crudCustomPolicy from '@/api/acs/device/customPolicy'
|
||||
import CRUD from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'CustomPolicyType',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
cruds() {
|
||||
return CRUD({ title: '自定义策略', url: 'api/customPolicy', idField: 'id', sort: 'id,desc', crudMethod: { ...crudCustomPolicy }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
requestMethodList: [{ code: 1, name: '上架' }, { code: 2, name: '下架' }, { code: 3, name: '摆渡' }],
|
||||
key_code: this.$route.query.key_code,
|
||||
id: this.$route.query.id,
|
||||
deviceList: [],
|
||||
modeform: {
|
||||
deviceCode: '',
|
||||
plans: [
|
||||
{
|
||||
from: '',
|
||||
to: '',
|
||||
quantity: null,
|
||||
type: null
|
||||
}
|
||||
]
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
}),
|
||||
selectById(this.id).then(data => {
|
||||
if (data != null && data != '') {
|
||||
console.log(data)
|
||||
this.modeform = data
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
insertdtl() {
|
||||
this.modeform.plans.push({ quantity: '', type: '' })
|
||||
},
|
||||
deleteRow(index, rows) {
|
||||
rows.splice(index, 1)
|
||||
},
|
||||
doSubmit() {
|
||||
updateConfig(this.modeform.plans, this.key_code, this.id).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
back() {
|
||||
this.$router.push('/devices/customPolicy')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user