Commit a61e43fb authored by 陈浩玮's avatar 陈浩玮

线路编排完成

parent ca9a6587
......@@ -145,3 +145,19 @@ export function getRouteAssemblesApi(data) {
export function getRouteAssemblesListApi(data) {
return getReq(`/ranger/inspection/api/v1/route/assembles/assembleList`, data);
}
export function addRouteAssemblesListApi(data) {
return postReq(`/ranger/inspection/api/v1/route/assembles`, data);
}
export function getPllaceListApi(data) {
return postReq('/ranger/inspection/api/v1/place/page', data);
}
export function updateRouteAssemblesApi(data) {
return putReq('/ranger/inspection/api/v1/route/assembles', data);
}
export function setRouteAssemblesOrderApi(data) {
return putReq('/ranger/inspection/api/v1/route/assembles/assembleOrder', data);
}
......@@ -16,7 +16,7 @@
<a-button>更多查询</a-button>
</a-popover>
<a-button @click="reset">重置</a-button>
<a-button type="primary" @click="getData">查询</a-button>
<a-button type="primary" @click="resetGetData">查询</a-button>
</a-space>
</div>
</my-card>
......@@ -246,6 +246,11 @@ export default {
this.getData();
},
resetGetData() {
this.initQuery = { ...initQuery };
this.getData();
},
refreshView() {
this.data = [...this.data];
},
......
<template>
<Table
url="/ranger/inspection/api/v1/place/page"
:rowKey="rowKey"
:selected.sync="selected"
addBtn
ref="addTable"
:otherQuery="otherQuery"
>
<template #search="{ query }">
<MoreItem label="线路名称">
<a-input v-model="query.inputValue" placeholder="请输入" />
</MoreItem>
</template>
<a-table-column title="地点名称" data-index="placeName" />
<a-table-column title="二维码" data-index="qrCode" />
<a-table-column title="电子标签" data-index="electronicTag" />
</Table>
</template>
<script>
import Table from '@/components/table/table.vue';
import MoreItem from '@/components/table/more_item.vue';
import { updateRouteStateApi } from '@/api';
export default {
components: { Table, MoreItem },
props: {
data: Object,
row: Object,
},
watch: {
row: {
handler(val) {
if (val) {
console.log(val);
} else {
const { regionId } = this.data;
this.otherQuery = { regionId };
this.rowKey = 'placeId';
}
},
deep: true,
immediate: true,
},
},
data() {
return {
selected: {},
otherQuery: {},
rowKey: 'regionId',
};
},
methods: {},
};
</script>
<template>
<Wraper :hidden="hidden" :refresh="refresh" :onOk="submit">
<Table
url="/ranger/inspection/api/v1/items"
rowKey="itemId"
:selected.sync="selected"
ref="addTable"
:otherQuery="otherQuery"
:width="552"
>
<template #search="{ query }">
<MoreItem label="项目名称">
<a-input v-model="query.inputValue" placeholder="请输入" />
</MoreItem>
</template>
<a-table-column title="项目名称" data-index="itemName" />
<a-table-column title="数据类型">
<template #default="row">
<span> {{ dataType[row.dataType] }}</span>
</template>
</a-table-column>
<a-table-column title="项目描述" data-index="equipmentCode" />
</Table>
</Wraper>
</template>
<script>
import Table from '@/components/table/table.vue';
import MoreItem from '@/components/table/more_item.vue';
import Wraper from '@/components/table/wraper.vue';
import { addRouteAssemblesListApi } from '@/api';
export default {
components: { Table, MoreItem, Wraper },
props: {
data: Object,
row: Object,
hidden: Function,
refresh: Function,
},
watch: {
row: {
handler(val) {
if (val) {
const { assembleObjectId, routeId, parentAssembleObjectId, regionId } = val;
this.otherQuery = { placeId: parentAssembleObjectId, unitId: assembleObjectId, regionId };
this.submitData = {
assembleObjectType: 'ITEM',
parentAssembleObjectType: 'UNIT',
parentAssembleObjectId: assembleObjectId,
routeId,
};
}
},
deep: true,
immediate: true,
},
},
data() {
return {
selected: {
keys: [],
},
otherQuery: {},
submitData: {},
dataType: {
TEXT: '文本类型',
OPTION: '选项类型',
NUMERIC: '数值类型',
},
};
},
methods: {
async submit() {
if (this.selected?.keys?.length !== 0) {
return await addRouteAssemblesListApi({
...this.submitData,
assembleObjectIdList: this.selected.keys,
});
}
this.$message.warning('请选择');
throw new Error('请选择');
},
},
};
</script>
<template>
<Wraper :hidden="hidden" :refresh="refresh" :onOk="submit">
<Table
url="/ranger/inspection/api/v1/place/page"
rowKey="placeId"
:selected.sync="selected"
:otherQuery="otherQuery"
:width="552"
>
<template #search="{ query }">
<MoreItem label="地点名称">
<a-input v-model="query.inputValue" placeholder="请输入" />
</MoreItem>
</template>
<a-table-column title="地点名称" data-index="placeName" />
<a-table-column title="二维码" data-index="qrCode" />
<a-table-column title="电子标签" data-index="electronicTag" />
<!-- <a-table-column v-if="rowKey === 'unitId'" title="单元名称" data-index="unitName" />
<a-table-column v-if="rowKey === 'unitId'" title="设备编号" data-index="equipmentCode" />
<a-table-column v-if="rowKey === 'itemId'" title="项目名称" data-index="itemName" />
<a-table-column v-if="rowKey === 'itemId'" title="数据类型" data-index="dataType" />
<a-table-column v-if="rowKey === 'itemId'" title="项目描述" data-index="equipmentCode" /> -->
</Table>
</Wraper>
</template>
<script>
import Table from '@/components/table/table.vue';
import MoreItem from '@/components/table/more_item.vue';
import Wraper from '@/components/table/wraper.vue';
import { addRouteAssemblesListApi } from '@/api';
export default {
components: { Table, MoreItem, Wraper },
props: {
data: Object,
row: Object,
hidden: Function,
refresh: Function,
},
watch: {
row: {
handler(val) {
if (val) {
const { regionId, routeId } = val;
this.otherQuery = { regionId };
this.submitData = {
assembleObjectType: 'PLACE',
parentAssembleObjectType: 'REGION',
parentAssembleObjectId: regionId,
routeId,
};
}
},
deep: true,
immediate: true,
},
},
data() {
return {
selected: {
keys: [],
},
otherQuery: {},
submitData: {},
};
},
methods: {
async submit() {
if (this.selected?.keys?.length !== 0) {
return await addRouteAssemblesListApi({
...this.submitData,
assembleObjectIdList: this.selected.keys,
});
}
this.$message.warning('请选择');
throw new Error('请选择');
},
},
};
</script>
<template>
<Wraper :hidden="hidden" :refresh="refresh" :onOk="submit">
<Table
url="/ranger/inspection/api/v1/units"
rowKey="unitId"
:selected.sync="selected"
:otherQuery="otherQuery"
:width="552"
>
<template #search="{ query }">
<MoreItem label="搜索">
<a-input v-model="query.inputValue" placeholder="请输入单元名称/设备编号" />
</MoreItem>
</template>
<a-table-column title="单元名称" data-index="unitName" />
<a-table-column title="设备编号" data-index="equipmentCode" />
</Table>
</Wraper>
</template>
<script>
import Table from '@/components/table/table.vue';
import MoreItem from '@/components/table/more_item.vue';
import Wraper from '@/components/table/wraper.vue';
import { addRouteAssemblesListApi } from '@/api';
export default {
components: { Table, MoreItem, Wraper },
props: {
row: Object,
hidden: Function,
refresh: Function,
},
watch: {
row: {
handler(val) {
if (val) {
const { assembleObjectId, routeId, parentAssembleObjectId } = val;
this.otherQuery = { regionId: parentAssembleObjectId, placeId: assembleObjectId };
this.submitData = {
assembleObjectType: 'UNIT',
parentAssembleObjectType: 'PLACE',
parentAssembleObjectId: assembleObjectId,
routeId,
};
}
},
deep: true,
immediate: true,
},
},
data() {
return {
selected: {
keys: [],
},
otherQuery: {},
submitData: {},
};
},
methods: {
async submit() {
if (this.selected?.keys?.length !== 0) {
return await addRouteAssemblesListApi({
...this.submitData,
assembleObjectIdList: this.selected.keys,
});
}
this.$message.warning('请选择');
throw new Error('请选择');
},
},
};
</script>
......@@ -4,7 +4,6 @@
url="/ranger/inspection/api/v1/route/assembles"
rowKey="assembleId"
:formatData="formatData"
addBtn
ref="assembleTable"
:scroll="scroll"
:otherQuery="getDefaultQuery()"
......@@ -13,36 +12,44 @@
noPadding
:width="400"
>
<template #operation>
<a-button type="primary" @click="addPlace">新增地点</a-button>
</template>
<template #drawer="drawer">
<Add v-bind="drawer" :data="row" />
<AddPlace v-if="addType === 'PLACE'" v-bind="drawer" :refresh="refresh" />
<AddUnit v-if="addType === 'UNIT'" v-bind="drawer" :refresh="refresh" />
<AddItem v-if="addType === 'ITEM'" v-bind="drawer" :refresh="refresh" />
</template>
<a-table-column title="名称" data-index="assembleObjectName" />
<a-table-column title="顺序">
<a-table-column title="名称" :width="150" data-index="assembleObjectName" />
<a-table-column title="顺序" :width="60">
<template #default="row">
<span v-if="row.assembleObjectType === 'PLACE'">{{ row.assembleOrder }}</span>
<span v-else>-</span>
</template>
</a-table-column>
<a-table-column title="类型">
<a-table-column title="类型" :width="60">
<template #default="row">
<span v-if="row.assembleObjectType === 'PLACE'">地点</span>
<span v-if="row.assembleObjectType === 'UNIT'">单元</span>
<span v-if="row.assembleObjectType === 'ITEM'">项目</span>
</template>
</a-table-column>
<a-table-column title="免检">
<a-table-column title="免检" :width="60">
<template #default="row">
<span :style="{ color: '#2db7f5' }" v-if="row.exemptionState === 'YES'">是</span>
<span :style="{ color: '#f5222d' }" v-if="row.exemptionState === 'NO'">否</span>
</template>
</a-table-column>
<a-table-column title="状态">
<a-table-column title="状态" :width="60">
<template #default="row">
<span :style="{ color: '#2db7f5' }" v-if="row.assembleState === 'VALID'">有效</span>
<span :style="{ color: '#f5222d' }" v-if="row.assembleState === 'INVALID'">无效</span>
</template>
</a-table-column>
<a-table-column title="描述" data-index="assembleDesc" />
<a-table-column title="描述" data-index="assembleDesc" :width="200" />
<template #other>
<SetOrder ref="setOrder" :afterSubmit="setRouteAssemblesOrder" />
</template>
</Table>
</Wraper>
</template>
......@@ -50,35 +57,88 @@
<script>
import Table from '@/components/table/table.vue';
import Wraper from '@/components/table/wraper.vue';
import { getRouteAssemblesListApi } from '@/api';
import Add from './add.vue';
import { getRouteAssemblesListApi, updateRouteAssemblesApi, setRouteAssemblesOrderApi } from '@/api';
import AddPlace from './addPlace.vue';
import AddUnit from './addUnit.vue';
import AddItem from './addItem.vue';
import SetOrder from './setOrder.vue';
export default {
components: { Wraper, Table, Add },
components: { Wraper, Table, AddPlace, AddUnit, AddItem, SetOrder },
props: { hidden: Function, row: Object },
data() {
return {
scroll: { x: 1300, y: 600 },
buttons: {
options: { width: 200, fixed: 'right' },
options: { width: 220, fixed: 'right' },
title: '操作',
data: [
{ label: '新增', click: () => {} },
{ label: '失效', click: () => {} },
{ label: '生效', click: () => {} },
{ label: '置顶', click: () => {} },
{ label: '排序', click: () => {} },
{
label: '新增单元',
click: this.addUnit,
isHidden: (row) => {
return row.assembleObjectType !== 'PLACE';
},
},
{
label: '新增项目',
click: this.addItem,
isHidden: (row) => {
return row.assembleObjectType !== 'UNIT';
},
},
{
label: '置顶',
click: this.toTop,
isHidden: (row) => {
return row.assembleObjectType !== 'PLACE';
},
},
{
label: '排序',
click: this.setOrder,
isHidden: (row) => {
return row.assembleObjectType !== 'PLACE';
},
},
{
label: '失效',
click: (row) => this.assembleUpdate(row, 'INVALID'),
isHidden: (row) => {
if (row.assembleObjectType === 'ITEM') {
return true;
} else {
return row.assembleState === 'INVALID';
}
},
},
{
label: '生效',
click: (row) => this.assembleUpdate(row, 'VALID'),
isHidden: (row) => {
if (row.assembleObjectType === 'ITEM') {
return true;
} else {
return row.assembleState === 'VALID';
}
},
},
{
type: 'confirm',
url: (row) => `/ranger/inspection/api/v1/routes/${row.routeId}`,
url: (row) => `/ranger/inspection/api/v1/route/assembles/${row.assembleId}`,
after: this.refresh,
},
],
},
addType: '',
};
},
mounted() {},
methods: {
refresh() {
this.$refs.assembleTable.resetGetData();
},
getDefaultQuery() {
const { routeId, regionId } = this.row;
return {
......@@ -87,6 +147,74 @@ export default {
routeId,
};
},
addPlace() {
const row = this.getDefaultQuery();
this.addType = 'PLACE';
this.$refs.assembleTable.show({ row, title: '新增地点', type: 'add' });
},
addUnit(row) {
this.addType = 'UNIT';
this.$refs.assembleTable.show({ row, title: '新增单元', type: 'add' });
},
addItem(row) {
this.addType = 'ITEM';
const newRow = { ...row, regionId: this.row.regionId };
this.$refs.assembleTable.show({ row: newRow, title: '新增项目', type: 'add' });
},
async assembleUpdate(row, assembleState) {
const {
assembleId,
assembleObjectId,
assembleObjectType,
parentAssembleObjectId,
parentAssembleObjectType,
routeId,
} = row;
const param = {
assembleState,
assembleId,
assembleObjectId,
assembleObjectType,
parentAssembleObjectId,
parentAssembleObjectType,
routeId,
};
const resp = await updateRouteAssemblesApi(param);
if (resp) {
this.$message.success('操作成功');
this.refresh();
} else {
this.$message.warning('操作失败');
}
},
toTop(row) {
const { assembleId, routeId } = row;
const param = {
assembleId,
routeId,
assembleOrder: 1,
};
this.setRouteAssemblesOrder(param);
},
setOrder(row) {
this.$refs.setOrder.setRow(row);
this.$refs.setOrder.showModal();
},
async setRouteAssemblesOrder(param) {
const resp = setRouteAssemblesOrderApi(param);
if (resp) {
this.$message.success('操作成功');
setTimeout(() => {
this.refresh();
}, 500);
} else {
this.$message.warning('操作失败');
}
},
formatData(list) {
return list.records.map((i) => {
return {
......@@ -103,7 +231,9 @@ export default {
parentAssembleObjectId: assembleObjectId,
assembleObjectType: assembleObjectType === 'PLACE' ? 'UNIT' : 'ITEM',
};
const resp = await getRouteAssemblesListApi(params);
const newData = resp.map((i) => {
return {
...i,
......@@ -113,6 +243,7 @@ export default {
};
});
record.children = newData;
this.$refs.assembleTable?.refreshView();
},
},
......
<template>
<a-modal
v-model="visible"
:title="`设置排序:${row.assembleObjectName}`"
@ok="handleOk"
destroyOnClose
:zIndex="1010"
>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
<a-form-model-item label="排序" prop="order">
<a-input-number :style="{ width: '100%' }" v-model="form.order" :min="1" :max="9999" />
</a-form-model-item>
</a-form-model>
</a-modal>
</template>
<script>
export default {
data() {
return {
visible: false,
form: {},
rules: {
order: [{ required: true }, { pattern: /^(0|[1-9][0-9]*)$/, message: '请输入正确的排序' }],
},
row: {
assembleObjectName: '',
},
};
},
props: {
afterSubmit: Function,
},
methods: {
showModal() {
this.form = {};
this.visible = true;
},
async handleOk(e) {
await this.$refs.form.validate();
const { assembleId, routeId } = this.row;
const param = {
assembleId,
routeId,
assembleOrder: this.form.order,
};
this.afterSubmit && this.afterSubmit(param);
this.closeModal();
},
closeModal() {
this.visible = false;
},
setRow(row) {
this.row = row;
},
},
};
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment