Commit 2d384b6b authored by 陈浩玮's avatar 陈浩玮

Merge branch 'feature/shuiluo' into 'master'

feat: 免检完成

See merge request product/kim3-web-vue/starter-web-vue!46
parents 35edb95a 006e0016
......@@ -47,3 +47,15 @@ export function editUnitApi(data) {
export function getUnitInfoApi(id) {
return getReq(`/ranger/inspection/api/v1/units/${id}`);
}
export function addExemptionApi(data) {
return postReq('/ranger/inspection/api/v1/exemptions', data);
}
export function getExemptionApi(id) {
return getReq(`ranger/inspection/api/v1/exemptions/${id}`);
}
export function updateExemptionApi(data) {
return putReq(`/ranger/inspection/api/v1/exemptions`, data);
}
<template>
<a-range-picker
@change="onChange"
style="width: 100%"
:showTime="showTime"
:value="value"
v-bind="$attrs"
/>
</template>
<script>
import moment from 'moment';
export default {
props: {
startTime: String,
endTime: String,
showTime: Boolean,
},
computed: {
value() {
return this.startTime ? [moment(this.startTime), moment(this.endTime)] : [];
},
},
methods: {
onChange(val, [startTimeString, endTimeString]) {
this.$emit('update:startTime', startTimeString);
this.$emit('update:endTime', endTimeString);
},
},
};
</script>
......@@ -98,6 +98,10 @@ export default {
noPadding: Boolean,
scroll: Object,
width: { type: Number, default: 900 },
defaultQuery: {
type: Object,
default: () => ({}),
},
},
data() {
......@@ -107,7 +111,7 @@ export default {
...initQuery,
},
data: [],
queryForm: {},
queryForm: { ...this.defaultQuery },
loading: false,
total: 0,
visible: false,
......@@ -206,7 +210,7 @@ export default {
},
reset() {
this.queryForm = {};
this.queryForm = { ...this.defaultQuery };
this.initQuery = { ...initQuery };
this.getData();
},
......
<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="exemptionType">
<a-select class="tw-w-full" v-model="form.exemptionType" :disabled="isView">
<a-select-option value="PLACE">地点免检</a-select-option>
<a-select-option value="UNIT">单元免检</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="所属地区" prop="regionId">
<UrlSelect
url="/ranger/inspection/api/v1/region/list"
v-model="form.regionId"
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="startTime">
<RangeTime
:startTime.sync="form.startTime"
:endTime.sync="form.endTime"
showTime
:disabled="isView"
/>
</a-form-model-item>
<a-form-model-item label="免检原因" prop="exemptionReason">
<a-textarea
placeholder="Basic usage"
:rows="4"
v-model="form.exemptionReason"
: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 RangeTime from '@/components/MySelect/range_time_select.vue';
import { addExemptionApi, updateExemptionApi, getExemptionApi } from '@/api';
export default {
components: { Wraper, UrlSelect, RangeTime },
props: { hidden: Function, row: Object, type: String, refresh: Function },
data: () => ({
form: {},
rules: {
exemptionType: [{ required: true }],
regionId: [{ required: true }],
placeId: [{ required: true }],
exemptionReason: [{ required: true }],
startTime: [{ required: true }],
},
}),
computed: {
isView() {
return this.type === 'view';
},
isEdit() {
return this.type === 'edit';
},
isAdd() {
return this.type === null;
},
},
async mounted() {
if (!this.isAdd) {
this.form = await getExemptionApi(this.row.exemptionId);
}
},
methods: {
async submit() {
await this.$refs.form.validate();
if (this.isAdd) return addExemptionApi(this.form);
if (this.isEdit) return updateExemptionApi(this.form);
},
},
};
</script>
import Index from './index.vue';
export default Index;
<template>
<Table
url="/ranger/inspection/api/v1/exemptions"
rowKey="exemptionId"
addBtn
:buttons="buttons"
ref="table"
:defaultQuery="defaultQuery"
>
<template #search="{ query }">
<MoreItem label="免检类型">
<a-select class="tw-w-full" v-model="query.exemptionType">
<a-select-option value="PLACE">地点免检</a-select-option>
<a-select-option value="UNIT">单元免检</a-select-option>
</a-select>
</MoreItem>
<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="单元" v-if="query.exemptionType === 'UNIT'">
<UrlSelect
v-model="query.unitId"
:url="query.placeId ? `/ranger/inspection/api/v1/units/places/${query.placeId}/list` : ''"
labelFiled="unitName"
valueFiled="unitId"
/>
</MoreItem>
</template>
<template #drawer="drawer">
<AddAndEdit v-bind="drawer" />
</template>
<a-table-column title="免检地点/单元名称" data-index="exemptionName" />
<a-table-column title="所属地区" data-index="regionName" />
<a-table-column title="类型">
<template #default="row">
<span>{{ row.exemptionType === 'PLACE' ? '地点免检' : '单元免检' }}</span>
</template>
</a-table-column>
<a-table-column title="开始时间" data-index="startTime" />
<a-table-column title="结束时间" data-index="endTime" />
<a-table-column title="原因" data-index="exemptionReason" />
<a-table-column title="免检状态" data-index="exemptionStateName" />
<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 {
defaultQuery: {
exemptionType: 'PLACE',
},
buttons: [
{ label: '编辑', click: this.edit },
{ label: '详情', click: this.view },
{
type: 'confirm',
url: (row) => `ranger/inspection/api/v1/exemptions/${row.exemptionId}`,
after: this.refresh,
},
],
};
},
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>
......@@ -72,7 +72,7 @@ const hasAuthorityRoutes = [
},
{
path: 'place',
name: '配置',
name: '配置',
component: () => import('@/pages/ranger/basic/place'),
},
{
......@@ -80,6 +80,11 @@ const hasAuthorityRoutes = [
name: '单元配置',
component: () => import('@/pages/ranger/basic/unit'),
},
{
path: 'exemption',
name: '免检配置',
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