Commit 21c7586c authored by 水落(YangLei)'s avatar 水落(YangLei)

Merge branch 'master' into feature/shuiluo

parents be882268 4721fe3b
...@@ -48,6 +48,18 @@ export function getUnitInfoApi(id) { ...@@ -48,6 +48,18 @@ export function getUnitInfoApi(id) {
return getReq(`/ranger/inspection/api/v1/units/${id}`); return getReq(`/ranger/inspection/api/v1/units/${id}`);
} }
<<<<<<< src/api/ranger.js
export function getItemsInfoApi(id) {
return getReq(`/ranger/inspection/api/v1/items/${id}`);
}
export function addItemsApi(data) {
return postReq('/ranger/inspection/api/v1/items', data);
}
export function editItemsApi(data) {
return putReq('/ranger/inspection/api/v1/items', data);
}
export function addExemptionApi(data) { export function addExemptionApi(data) {
return postReq('/ranger/inspection/api/v1/exemptions', data); return postReq('/ranger/inspection/api/v1/exemptions', data);
} }
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
:title="newButtons.title" :title="newButtons.title"
v-if="this.newButtons" v-if="this.newButtons"
v-bind="this.newButtons.options" v-bind="this.newButtons.options"
fixed="right"
width="180"
> >
<template #default="row"> <template #default="row">
<my-ac-btn :row="row" :buttons="newButtons.data" /> <my-ac-btn :row="row" :buttons="newButtons.data" />
......
<template>
<Wraper :hidden="hidden" :onOk="submit" :refresh="refresh" :noFooter="isView">
<a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
<a-form-model-item label="项目名称" prop="placeName">
<a-input v-model="form.placeName" :disabled="isView" />
</a-form-model-item>
<a-form-model-item label="所属地区" prop="regionId">
<UrlSelect
v-model="form.regionId"
url="/ranger/inspection/api/v1/region/list"
labelFiled="regionName"
valueFiled="regionId"
:disabled="isView"
/>
</a-form-model-item>
<a-form-model-item label="所属地点" prop="placeId">
<UrlSelect
v-model="form.placeId"
:url="
form.regionId ? `/ranger/inspection/api/v1/place/regions/${form.regionId}/list` : ''
"
labelFiled="placeName"
valueFiled="placeId"
:disabled="isView"
/>
</a-form-model-item>
<a-form-model-item label="所属单元" prop="unitId">
<UrlSelect
v-model="form.unitId"
:url="form.placeId ? `/ranger/inspection/api/v1/units/places/${form.placeId}/list` : ''"
labelFiled="unitName"
valueFiled="unitId"
:disabled="isView"
/>
</a-form-model-item>
<a-form-model-item label="数据类型" prop="dataType">
<a-select v-model="form.dataType" :disabled="isView">
<a-select-option key="TEXT" value="TEXT">文本类型</a-select-option>
<a-select-option key="OPTION" value="OPTION">选项类型</a-select-option>
<a-select-option key="NUMERIC" value="NUMERIC">数值类型</a-select-option>
</a-select>
</a-form-model-item>
<div v-if="form.dataType === 'TEXT'">
<a-form-model-item label="默认值" prop="defaultText">
<a-textarea
placeholder="Basic usage"
:rows="4"
v-model="form.defaultText"
:disabled="isView"
/>
</a-form-model-item>
</div>
<div v-if="form.dataType === 'OPTION'">
<a-form-model-item label="选项类型" prop="optionType">
<a-select v-model="form.optionType" :disabled="isView">
<a-select-option key="TEXT" value="TEXT">开/关</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="正常值" prop="normalValue">
<a-select v-model="form.normalValue" :disabled="isView">
<a-select-option key="1" value="1"></a-select-option>
<a-select-option key="0" value="0"></a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="异常值" prop="abnormalValue">
<a-select v-model="form.abnormalValue" :disabled="isView">
<a-select-option key="1" value="1"></a-select-option>
<a-select-option key="0" value="0"></a-select-option>
</a-select>
</a-form-model-item>
</div>
<div v-if="form.dataType === 'NUMERIC'">
<a-form-model-item label="默认值" prop="defaultValue">
<a-input v-model="form.defaultValue" placeholder="请输入" />
</a-form-model-item>
<a-form-model-item label="上限值" prop="upperLimitValue">
<a-input v-model="form.upperLimitValue" placeholder="请输入" />
</a-form-model-item>
<a-form-model-item label="下限值" prop="lowerLimitValue">
<a-input v-model="form.lowerLimitValue" placeholder="请输入" />
</a-form-model-item>
</div>
<a-form-model-item label="备注" prop="remark">
<a-textarea placeholder="Basic usage" :rows="4" v-model="form.remark" :disabled="isView" />
</a-form-model-item>
</a-form-model>
</Wraper>
</template>
<script>
import Wraper from '@/components/table/wraper.vue';
import UrlSelect from '@/components/MySelect/url_select.vue';
import { addItemsApi, editItemsApi, getItemsInfoApi } from '@/api';
export default {
components: { Wraper, UrlSelect },
props: { hidden: Function, row: Object, type: String, refresh: Function },
data() {
let normalValueValidator = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password'));
} else {
if (this.form.abnormalValue) {
if (value === this.form.abnormalValue) {
callback(new Error('Please input the password'));
} else {
callback();
}
} else {
callback();
}
}
};
let abnormalValueValidator = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password'));
} else {
if (this.form.abnormalValue) {
if (value === this.form.abnormalValue) {
callback(new Error('Please input the password'));
} else {
callback();
}
} else {
callback();
}
}
};
let defaultValueValidator = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password'));
} else {
if (this.form.upperLimitValue && this.form.lowerLimitValue) {
if (this.form.upperLimitValue > value && value > this.form.lowerLimitValue) {
callback();
} else {
callback(new Error('数值错误'));
}
} else if (this.form.upperLimitValue) {
if (this.form.upperLimitValue > value) {
callback();
} else {
callback(new Error('数值错误1'));
}
} else if (this.form.lowerLimitValue) {
if (this.form.lowerLimitValue < value) {
callback();
} else {
callback(new Error('数值错误2'));
}
} else {
callback();
}
}
};
let upperLimitValueValidator = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password'));
} else {
if (this.form.defaultValue && this.form.lowerLimitValue) {
if (this.form.defaultValue < value && value > this.form.lowerLimitValue) {
callback();
} else {
callback(new Error('数值错误'));
}
} else if (this.form.defaultValue) {
if (this.form.defaultValue < value) {
callback();
} else {
callback(new Error('数值错误1'));
}
} else if (this.form.lowerLimitValue) {
if (this.form.lowerLimitValue < value) {
callback();
} else {
callback(new Error('数值错误2'));
}
} else {
callback();
}
}
};
let lowerLimitValueValidator = (rule, value, callback) => {
if (value === '') {
callback(new Error('Please input the password'));
} else {
if (this.form.defaultValue && this.form.upperLimitValue) {
if (this.form.defaultValue > value && value < this.form.upperLimitValue) {
callback();
} else {
callback(new Error('数值错误'));
}
} else if (this.form.defaultValue) {
if (this.form.defaultValue > value) {
callback();
} else {
callback(new Error('数值错误1'));
}
} else if (this.form.upperLimitValue) {
if (this.form.upperLimitValue > value) {
callback();
} else {
callback(new Error('数值错误2'));
}
} else {
callback();
}
}
};
return {
form: {},
rules: {
placeName: [{ required: true }],
placeId: [{ required: true }],
regionId: [{ required: true }],
unitId: [{ required: true }],
dataType: [{ required: true }],
defaultText: [{ required: true }],
optionType: [{ required: true }],
normalValue: [
{ required: true },
{
validator: normalValueValidator,
},
],
abnormalValue: [{ required: true }, { validator: abnormalValueValidator }],
defaultValue: [{ required: true }, { validator: defaultValueValidator }],
upperLimitValue: [{ required: true }, { validator: upperLimitValueValidator }],
lowerLimitValue: [{ required: true }, { validator: lowerLimitValueValidator }],
},
};
},
computed: {
isView() {
return this.type === 'view';
},
isEdit() {
return this.type === 'edit';
},
isAdd() {
return this.type === null;
},
},
async mounted() {
if (!this.isAdd) {
this.form = await getItemsInfoApi(this.row.itemId);
}
},
methods: {
async submit() {
await this.$refs.form.validate();
if (this.isAdd) return addItemsApi(this.form);
if (this.isEdit) return editItemsApi(this.form);
},
},
};
</script>
<template>
<Table
url="/ranger/inspection/api/v1/items"
rowKey="itemId"
addBtn
:buttons="buttons"
ref="table"
:scroll="{ x: true }"
>
<template #search="{ query }">
<MoreItem label="地区">
<UrlSelect
url="/ranger/inspection/api/v1/region/list"
v-model="query.regionId"
labelFiled="regionName"
valueFiled="regionId"
/>
</MoreItem>
<MoreItem label="地点">
<UrlSelect
v-model="query.placeId"
:url="
query.regionId ? `/ranger/inspection/api/v1/place/regions/${query.regionId}/list` : ''
"
labelFiled="placeName"
valueFiled="placeId"
/>
</MoreItem>
<MoreItem label="单元">
<UrlSelect
v-model="query.unitId"
:url="query.placeId ? `/ranger/inspection/api/v1/units/places/${query.placeId}/list` : ''"
labelFiled="unitName"
valueFiled="unitId"
/>
</MoreItem>
<MoreItem label="项目名称">
<a-input v-model="query.inputValue" placeholder="请输入项目名称" />
</MoreItem>
</template>
<!-- <template #operation>
<a-button @click="download">导出</a-button>
</template> -->
<template #drawer="drawer">
<AddAndEdit v-bind="drawer" />
</template>
<a-table-column title="项目名称" data-index="itemName" />
<a-table-column title="所属单元" data-index="unitName" />
<a-table-column title="数据类型">
<template #default="row">
<span> {{ dataType[row.dataType] }}</span>
</template>
</a-table-column>
<a-table-column title="项目描述">
<template #default="row">
<span v-if="row.dataType === 'TEXT'"> {{ row.defaultText }}</span>
<span v-if="row.dataType === 'OPTION'">
{{ `正常值:${row.normalValue} 异常值:${row.abnormalValue}` }}</span
>
<span v-if="row.dataType === 'NUMERIC'">
{{
`默认值:${row.defaultValue} 上限值:${row.upperLimitValue} 下限值:${row.lowerLimitValue}`
}}</span
>
</template>
</a-table-column>
<a-table-column title="修改人" data-index="editorName" />
<a-table-column title="修改时间" data-index="editTime" />
</Table>
</template>
<script>
import Table from '@/components/table/table.vue';
import UrlSelect from '@/components/MySelect/url_select.vue';
import MoreItem from '@/components/table/more_item.vue';
import AddAndEdit from './add_edit.vue';
export default {
components: { Table, UrlSelect, MoreItem, AddAndEdit },
data() {
return {
buttons: [
{ label: '编辑', click: this.edit },
{ label: '详情', click: this.view },
{
type: 'confirm',
url: (row) => `/ranger/inspection/api/v1/items/${row.itemId}`,
after: this.refresh,
},
],
dataType: {
TEXT: '文本类型',
OPTION: '选项类型',
NUMERIC: '数值类型',
},
};
},
methods: {
refresh() {
this.$refs.table.getData();
},
edit(row) {
this.$refs.table.show({ row, title: '编辑', type: 'edit' });
},
view(row) {
this.$refs.table.show({ row, title: '查看', type: 'view' });
},
},
};
</script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<a-input v-model="form.placeName" :disabled="isView" /> <a-input v-model="form.placeName" :disabled="isView" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="所属组织" prop="regionId"> <a-form-model-item label="所属地区" prop="regionId">
<UrlSelect <UrlSelect
v-model="form.regionId" v-model="form.regionId"
url="/ranger/inspection/api/v1/region/list" url="/ranger/inspection/api/v1/region/list"
......
...@@ -86,9 +86,15 @@ const hasAuthorityRoutes = [ ...@@ -86,9 +86,15 @@ const hasAuthorityRoutes = [
component: () => import('@/pages/ranger/basic/major'), component: () => import('@/pages/ranger/basic/major'),
}, },
{ {
path: 'item',
name: '项目配置',
component: () => import('@/pages/ranger/basic/item'),
},{
path: 'exemption', path: 'exemption',
name: '免检配置', name: '免检配置',
component: () => import('@/pages/ranger/basic/exemption'), component: () => import('@/pages/ranger/basic/exemption'),
}, },
], ],
}, },
......
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