Commit dde19e69 by zhuxiaomei

维护人员地点

parent c55e1d4c
......@@ -4,6 +4,7 @@
"private": true,
"scripts": {
"serve": "vue-cli-service serve --mode development",
"devtest": "vue-cli-service serve --mode devtest",
"build": "vue-cli-service build --mode production",
"pertest": "vue-cli-service build --mode pertest",
"lint": "vue-cli-service lint"
......
......@@ -14,6 +14,7 @@ export default {
add:data=>http.post('/drs/v1/sampling_plan/', data).then(res=>res),
addPlan:data=>http.post('/drs/v1/sampling_plan/add_plan', data).then(res=>res),
edit:data=>http.put('/drs/v1/sampling_plan/' + data.id, data.obj).then(res=>res),
deleteByIds:ids=>http.delete('/drs/v1/sampling_plan/?ids=' + ids).then(res=>res),
......@@ -26,4 +27,6 @@ export default {
samplerPage:data=>http.post('/drs/v1/sampling_plan/search_plan_sampler', data).then(res=>res),
saveSampler:data=>http.post('/drs/v1/sampling_plan/save_plan_sampler', data).then(res=>res),
deletePlanSampler:data=>http.post('/drs/v1/sampling_plan/delete_plan_sampler', data).then(res=>res),
saveSubmitPlan:data=>http.post('/drs/v1/sampling_plan/save_submit_plan', data).then(res=>res),
getSamplerPlace:data=>http.post('/drs/v1/sampling_plan/search_selected_sampler_place', data).then(res=>res),
}
......@@ -6,7 +6,7 @@
<div>
<img src="@/assets/home/plan.png"></div>
<div>
<div class="title">抽样计划执行双随机</div>
<div class="title">我创建的抽样计划</div>
<!--todo 每个模块的数量-->
<div class="num">3</div>
</div>
......@@ -17,7 +17,7 @@
<div class="box-img">
<img src="@/assets/home/task.png"></div>
<div class="cont">
<div class="title">我的任务</div>
<div class="title">我的双随机任务</div>
<div class="num">4</div>
</div>
</div>
......
<template>
<div>
<van-field label="人员" center>
<template #input>
<Tag v-for="(item,index) in userList" :key="item.id" :name="index" closable @on-close="_userHandleClose">
{{ item.name }}
</Tag>
<van-button size="small" type="default" @click="_userAdd">添加</van-button>
</template>
</van-field>
<van-field label="地点" center>
<template #input>
<Tag v-for="(item,index) in locList" :key="item.id" :name="index" closable @on-close="_locHandleClose">
{{ item.name }}
</Tag>
<van-button size="small" type="default" @click="_locAdd">手动添加</van-button>
<van-button size="small" type="default" @click="_locSearch" style="margin-left: 10px">搜索选择</van-button>
</template>
</van-field>
<van-popup v-model="showUserSelect">
<SamplerLab @cancel="showUserSelect=false" @on-change="_selectUserChange"
ref="userSelect"></SamplerLab>
</van-popup>
<van-popup v-model="showLocAdd">
<customer-navBar-layout style="width: 100vw;height:100vh">
<template #navBar>
<van-nav-bar
title="添加地点"
left-arrow
@click-left="showLocAdd=false"
></van-nav-bar>
</template>
<template #content>
<div class="layout-cont pop-page-cont">
<LocAdd @on-change="_addLocChange" ref="locAdd"></LocAdd>
</div>
</template>
</customer-navBar-layout>
</van-popup>
<van-popup v-model="showLocSelect">
<customer-navBar-layout style="width: 100vw;height:100vh">
<template #navBar>
<van-nav-bar
title="选择地点"
left-arrow
@click-left="showLocSelect=false"
></van-nav-bar>
</template>
<template #content>
<div class="layout-cont pop-page-cont">
<SelectLoc @on-change="_selectLocChange" ref="locSelect"></SelectLoc>
</div>
</template>
</customer-navBar-layout>
</van-popup>
<div class="bottom-btn" style="position: fixed;bottom: 0">
<van-button type="info" block @click="_create">随机生成</van-button>
</div>
</div>
</template>
<script>
import {samplingPlace, samplingPlan} from "../../api";
import SamplerLab from './sampler/SamplerLab'
import LocAdd from './loc/LocAdd'
import SelectLoc from './loc/SelectLoc'
export default {
components: {
SamplerLab,
LocAdd,
SelectLoc,
},
data() {
return {
planId: '',
userList: [],
locList: [],
showUserSelect: false,
showLocAdd: false,
showLocSelect: false,
}
},
mounted() {
this.planId = this.$route.query.planId
this._getUserList()
this._getLocList()
},
methods: {
_getUserList: async function () {
const page = await samplingPlan.samplerPage({page: 1, rows: 1000, planId: this.planId})
this.userList = page ? page.records : []
},
_getLocList: async function () {
const page = await samplingPlace.page({page: 1, rows: 1000, planId: this.planId})
this.locList = page ? page.records : []
},
_userAdd() {
this.showUserSelect = true
this.$nextTick(function () {
this.$refs.userSelect._open(this.planId)
})
},
_locAdd() {
this.showLocAdd = true
this.$nextTick(function () {
this.$refs.locAdd._open(this.planId)
})
},
_locSearch() {
this.showLocSelect = true
this.$nextTick(function () {
this.$refs.locSelect._open(this.planId)
})
},
_selectUserChange() {
this.showUserSelect = false
this._getUserList()
},
_addLocChange() {
this.showLocAdd = false
this._getLocList()
},
_selectLocChange() {
this.showLocSelect = false
this._getLocList()
},
_userHandleClose: async function (event, index) {
const result = await samplingPlan.deletePlanSampler({samplerId: this.userList[index].id, planId: this.planId})
if (result) {
this.userList.splice(index, 1);
}
},
_locHandleClose: async function (event, index) {
const result = await samplingPlace.deleteByIds(this.locList[index].id)
if (result) {
this.locList.splice(index, 1);
}
},
_create() {
this.$router.push({path:'/sampling_plan/random_create',query:{planId:this.planId}})
},
}
}
</script>
<style scoped>
.pop-page-cont > div {
width: 100%;
height: 100%;
}
</style>
<template>
<customer-navBar-layout>
<template #navBar>
<van-nav-bar v-if="showCheck"
:title="$route.meta.title"
right-text="取消"
left-arrow
@click-left="_back"
@click-right="_hideCheck">
</van-nav-bar>
<van-nav-bar
v-else
:title="$route.meta.title"
right-text="添加"
left-arrow
@click-left="_back"
@click-right="_add"
></van-nav-bar>
<customer-navBar-layout>
<template #navBar>
<van-nav-bar v-if="showCheck"
:title="$route.meta.title"
right-text="取消"
left-arrow
@click-left="_back"
@click-right="_hideCheck">
</van-nav-bar>
<van-nav-bar
v-else
:title="$route.meta.title"
right-text="添加"
left-arrow
@click-left="_back"
@click-right="_add"
></van-nav-bar>
</template>
<template #content>
<search-bar label="计划名称" ref="searchBar"
highSearch @search="_search" @high-search="_highSearch"
@clear-high="_clearHigh">
<template #highSearch>
<van-field v-model="formObj.name" label="计划名称" placeholder="请输入计划名称"></van-field>
<datetime-field label="计划开始日期" v-model="formObj.planDateBegin"></datetime-field>
<datetime-field label="计划结束日期" v-model="formObj.planDateEnd"></datetime-field>
<van-field v-model="formObj.uname" label="登记人" placeholder="请输入登记人"></van-field>
<datetime-field label="登记开始日期" v-model="formObj.ctimeBegin"></datetime-field>
<datetime-field label="登记结束日期" v-model="formObj.ctimeEnd"></datetime-field>
<picker-field label="状态" v-model="formObj.progress" :columns="statusList"
show-key="text"></picker-field>
</template>
<template #content>
<search-bar label="计划名称" ref="searchBar"
highSearch @search="_search" @high-search="_highSearch"
@clear-high="_clearHigh">
<template #highSearch>
<van-field v-model="formObj.name" label="计划名称" placeholder="请输入计划名称"></van-field>
<datetime-field label="计划开始日期" v-model="formObj.planDateBegin"></datetime-field>
<datetime-field label="计划结束日期" v-model="formObj.planDateEnd"></datetime-field>
<van-field v-model="formObj.uname" label="登记人" placeholder="请输入登记人"></van-field>
<datetime-field label="登记开始日期" v-model="formObj.ctimeBegin"></datetime-field>
<datetime-field label="登记结束日期" v-model="formObj.ctimeEnd"></datetime-field>
<picker-field label="状态" v-model="formObj.progress" :columns="statusList"
show-key="text"></picker-field>
</search-bar>
<div class="layout-cont-sh" :class="{'layout-cont-sh-btn':showCheck}">
<!--下拉刷新 https://vant-contrib.gitee.io/vant/#/zh-CN/pull-refresh-->
<van-pull-refresh v-model="refreshing" @refresh="_refresh">
<!--上拉加载 https://vant-contrib.gitee.io/vant/#/zh-CN/list-->
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="_load">
<van-checkbox-group v-model="checkListValue" ref="checkboxGroup">
<van-swipe-cell v-for="item in resultList" :key="item.id">
<div class="result-item" @click="_tapItem(item)" v-touch:longtap="_longtapHandler">
<div
style="width: 100%;display: flex;justify-content: space-between;border-bottom: 1px solid #eeeeee">
<div style="display: flex">
<div style="margin-right: 20px" v-if="showCheck">
<van-checkbox :name="item.id" shape="square"></van-checkbox>
</div>
<div>计划名称:{{ item.name }}</div>
</div>
<div @click.stop="_goFile(item.id)">
<img src="../../assets/file-nav.png" style="width: 20px">
</div>
</div>
<div>状态:{{ item.progress }}</div>
<div>计划日期:{{ $dateformat(item.planDate, 'yyyy-mm-dd') }}</div>
<div>任务下达单位:{{ item.issuingUnit }}</div>
<div>任务来源:{{ item.taskSource }}</div>
<div style="width: 100%">抽样人员:{{ item.samplerNames }}</div>
<div style="width: 100%">抽样地点:{{ item.placeNames }}</div>
<div>抽样进度:{{ item.completionRatio }}</div>
<div>产品:{{ item.product }}</div>
</div>
<template #right v-if="item.progress==='草稿'||item.progress==='审批驳回'">
<van-button square color="#75b7bd" text="提交 " class="swipe-cell-btn"
@click="_submit([item.id])"></van-button>
<!-- <van-button square type="info" text="编辑" class="swipe-cell-btn"-->
<!-- @click="_edit(item)"></van-button>-->
<!-- <van-button square type="primary" text="管理人员" class="swipe-cell-btn"-->
<!-- @click="_peopleManage(item)"></van-button>-->
<!-- <van-button square type="warning" text="管理地点" class="swipe-cell-btn"-->
<!-- @click="_locManage(item)"></van-button>-->
<van-button square type="warning" text="维护人员地点" class="swipe-cell-btn"
@click="_maintain(item)"></van-button>
<van-button square type="danger" text="删除" class="swipe-cell-btn"
@click="_del([item.id])"></van-button>
</template>
</search-bar>
<div class="layout-cont-sh" :class="{'layout-cont-sh-btn':showCheck}">
<!--下拉刷新 https://vant-contrib.gitee.io/vant/#/zh-CN/pull-refresh-->
<van-pull-refresh v-model="refreshing" @refresh="_refresh">
<!--上拉加载 https://vant-contrib.gitee.io/vant/#/zh-CN/list-->
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="_load">
<van-checkbox-group v-model="checkListValue" ref="checkboxGroup">
<van-swipe-cell v-for="item in resultList" :key="item.id">
<div class="result-item" @click="_tapItem(item)" v-touch:longtap="_longtapHandler">
<div style="width: 100%;display: flex;justify-content: space-between;border-bottom: 1px solid #eeeeee">
<div style="display: flex">
<div style="margin-right: 20px" v-if="showCheck">
<van-checkbox :name="item.id" shape="square"></van-checkbox>
</div>
<div>计划名称:{{item.name}}</div>
</div>
<div @click.stop="_goFile(item.id)">
<img src="../../assets/file-nav.png" style="width: 20px">
</div>
</div>
<div>状态:{{item.progress}}</div>
<div>计划日期:{{$dateformat(item.planDate,'yyyy-mm-dd')}}</div>
<div>任务下达单位:{{item.issuingUnit}}</div>
<div>任务来源:{{item.taskSource}}</div>
<div style="width: 100%">抽样人员:{{item.samplerNames}}</div>
<div style="width: 100%">抽样地点:{{item.placeNames}}</div>
<div>抽样进度:{{item.completionRatio}}</div>
<div>产品:{{item.product}}</div>
</div>
<template #right v-if="item.progress==='草稿'||item.progress==='审批驳回'">
<van-button square color="#75b7bd" text="提交 " class="swipe-cell-btn"
@click="_submit([item.id])"></van-button>
<van-button square type="info" text="编辑" class="swipe-cell-btn"
@click="_edit(item)"></van-button>
<van-button square type="primary" text="管理人员" class="swipe-cell-btn"
@click="_peopleManage(item)"></van-button>
<van-button square type="warning" text="管理地点" class="swipe-cell-btn"
@click="_locManage(item)"></van-button>
<van-button square type="danger" text="删除" class="swipe-cell-btn"
@click="_del([item.id])"></van-button>
</template>
</van-swipe-cell>
</van-checkbox-group>
</van-list>
</van-pull-refresh>
</div>
<div class="bottom-btn" v-if="showCheck">
<van-button square block @click="_checkAll">{{checkAll?'取消全选':'全选'}}</van-button>
<van-button square block type="danger" @click="_del(checkListValue)">删除</van-button>
<van-button square block type="info" @click="_submit(checkListValue)">提交</van-button>
</div>
</template>
</customer-navBar-layout>
</van-swipe-cell>
</van-checkbox-group>
</van-list>
</van-pull-refresh>
</div>
<div class="bottom-btn" v-if="showCheck">
<van-button square block @click="_checkAll">{{ checkAll ? '取消全选' : '全选' }}</van-button>
<van-button square block type="danger" @click="_del(checkListValue)">删除</van-button>
<van-button square block type="info" @click="_submit(checkListValue)">提交</van-button>
</div>
</template>
</customer-navBar-layout>
</template>
<script>
import {samplingPlan} from '../../api'
import {samplingPlan} from '../../api'
export default {
name: "SamplingPlan",
components: {},
data() {
return {
formObj: {
name: '',
planDateBegin: '',
planDateEnd: '',
uname: '',
ctimeBegin: '',
ctimeEnd: '',
progress: '',
flag: 0
},
statusList: [
{value: 1, text: '草稿'},
{value: 2, text: '审批中'},
{value: 3, text: '审批通过'},
{value: 4, text: '审批驳回'},
{value: 5, text: '实施中'},
{value: 6, text: '完成'},
],
key: '',
showPopup: true,
showCheck: false,
checkListValue: [],
resultList: [],
page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
planId: this.$route.query.planId
}
},
watch: {
checkListValue: function (oldVal, newVal) {
console.log(oldVal, newVal)
}
},
computed: {
checkAll: function () {
if (this.resultList.length) {
return this.checkListValue.length === this.resultList.length;
} else {
return false
}
}
},
mounted() {
this._getData()
},
methods: {
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this.formObj = this.$resetFields(this.formObj)
this.formObj.flag = 0
this._refresh()
},
//高级搜索 清空key 查询
_highSearch() {
this.key = ''
if (this._valParams()) {
this.$refs.searchBar._hideHighSearch()
this._refresh()
}
},
_valParams() {
if (this.formObj.planDateBegin === '' && this.formObj.planDateEnd !== '') {
this.$toast('请选择计划开始日期!')
return false
} else if (this.formObj.planDateBegin !== '' && this.formObj.planDateEnd === '') {
this.$toast('请选择计划结束日期!')
return false
} else if (this.formObj.planDateBegin !== '' && this.formObj.planDateEnd !== '' && (new Date(this.formObj.planDateBegin) > new Date(this.formObj.planDateEnd))) {
this.$toast('计划开始日期不能大于计划结束日期!')
return false
}
if (this.formObj.ctimeBegin === '' && this.formObj.ctimeEnd !== '') {
this.$toast('请选择登记开始日期!')
return false
} else if (this.formObj.ctimeBegin !== '' && this.formObj.ctimeEnd === '') {
this.$toast('请选择登记结束日期!')
return false
} else if (this.formObj.ctimeBegin !== '' && this.formObj.ctimeEnd !== '' && (new Date(this.formObj.ctimeBegin) > new Date(this.formObj.ctimeEnd))) {
this.$toast('登记开始日期不能大于登记结束日期!')
return false
}
return true
},
_clearHigh() {
this.formObj = this.$resetFields(this.formObj)
this.formObj.flag = 0
},
_searchParams() {
let data = {
page: this.page,
rows: this.rows,
planId: this.planId,
...this.formObj
};
if (this.key) {
data.name = this.key
}
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingPlan.page(this._searchParams())
this.resultList = [...(this.page === 1 ? [] : this.resultList), ...result.records]
this.refreshing = false
this.loading = false
if (this.resultList.length === result.total) {
this.finished = true
}
},
_refresh() {
this.page = 1;
this._getData()
},
_load() {
this.page = this.page + 1;
this._getData()
},
_back() {
this.$router.go(-1)
},
_add() {
this.$router.push({path: '/sampling_plan/sampling_plan_add', query: {title: '抽样计划添加'}})
},
_longtapHandler() {
this.showCheck = true
},
_hideCheck() {
this.showCheck = false
this.checkListValue = []
},
_checkAll() {
if (this.checkAll) {
this.$refs.checkboxGroup.toggleAll();
} else {
this.$refs.checkboxGroup.toggleAll(true);
}
},
_tapItem(item) {
if (this.showCheck) {
if (this.checkListValue.indexOf(item.id) === -1) {
this.checkListValue.push(item.id);
} else {
this.checkListValue.splice(this.checkListValue.indexOf(item.id), 1);
}
} else {
// if (item.testedType === 1) {
// this.$router.push({path: '/sampling_plan/sampling_plan_detail_net', query: {id: item.id}})
// } else if (item.testedType === 0) {
// this.$router.push({path: '/sampling_plan/sampling_plan_detail', query: {id: item.id}})
// } else {
// this.$router.push({
// path: '/sampling_plan/sampling_plan_detail_agriculture',
// query: {id: item.id}
// })
// }
}
},
_edit(item) {
this.$router.push({path: '/sampling_plan/sampling_plan_add', query: {id: item.id, title: '抽样计划编辑'}})
},
_peopleManage(item) {
this.$router.push({path: '/sampling_plan/sampler_checked', query: {planId: item.id}})
},
_locManage(item) {
this.$router.push({path: '/sampling_plan/loc_checked', query: {planId: item.id}})
},
_del(ids) {
if (ids.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
this._delOk(ids)
}
},
_delOk: async function (ids) {
let result = await samplingPlan.deleteByIds(ids)
if (result) {
this.$toast('操作成功!')
this._refresh()
}
},
_submit() {
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
// this._delOk(ids)
// todo 提交
}
},
_goFile(id) {
this.$router.push({path: '/sampling_plan/file', query: {planId: id}})
}
export default {
name: "SamplingPlan",
components: {},
data() {
return {
formObj: {
name: '',
planDateBegin: '',
planDateEnd: '',
uname: '',
ctimeBegin: '',
ctimeEnd: '',
progress: '',
flag: 0
},
statusList: [
{value: 1, text: '草稿'},
{value: 2, text: '审批中'},
{value: 3, text: '审批通过'},
{value: 4, text: '审批驳回'},
{value: 5, text: '实施中'},
{value: 6, text: '完成'},
],
key: '',
showPopup: true,
showCheck: false,
checkListValue: [],
resultList: [],
page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
planId: this.$route.query.planId
}
},
watch: {
checkListValue: function (oldVal, newVal) {
console.log(oldVal, newVal)
}
},
computed: {
checkAll: function () {
if (this.resultList.length) {
return this.checkListValue.length === this.resultList.length;
} else {
return false
}
}
},
mounted() {
this._getData()
},
methods: {
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this.formObj = this.$resetFields(this.formObj)
this.formObj.flag = 0
this._refresh()
},
//高级搜索 清空key 查询
_highSearch() {
this.key = ''
if (this._valParams()) {
this.$refs.searchBar._hideHighSearch()
this._refresh()
}
},
_valParams() {
if (this.formObj.planDateBegin === '' && this.formObj.planDateEnd !== '') {
this.$toast('请选择计划开始日期!')
return false
} else if (this.formObj.planDateBegin !== '' && this.formObj.planDateEnd === '') {
this.$toast('请选择计划结束日期!')
return false
} else if (this.formObj.planDateBegin !== '' && this.formObj.planDateEnd !== '' && (new Date(this.formObj.planDateBegin) > new Date(this.formObj.planDateEnd))) {
this.$toast('计划开始日期不能大于计划结束日期!')
return false
}
if (this.formObj.ctimeBegin === '' && this.formObj.ctimeEnd !== '') {
this.$toast('请选择登记开始日期!')
return false
} else if (this.formObj.ctimeBegin !== '' && this.formObj.ctimeEnd === '') {
this.$toast('请选择登记结束日期!')
return false
} else if (this.formObj.ctimeBegin !== '' && this.formObj.ctimeEnd !== '' && (new Date(this.formObj.ctimeBegin) > new Date(this.formObj.ctimeEnd))) {
this.$toast('登记开始日期不能大于登记结束日期!')
return false
}
return true
},
_clearHigh() {
this.formObj = this.$resetFields(this.formObj)
this.formObj.flag = 0
},
_searchParams() {
let data = {
page: this.page,
rows: this.rows,
planId: this.planId,
...this.formObj
};
if (this.key) {
data.name = this.key
}
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingPlan.page(this._searchParams())
this.resultList = [...(this.page === 1 ? [] : this.resultList), ...result.records]
this.refreshing = false
this.loading = false
if (this.resultList.length === result.total) {
this.finished = true
}
},
_refresh() {
this.page = 1;
this._getData()
},
_load() {
this.page = this.page + 1;
this._getData()
},
_back() {
this.$router.go(-1)
},
_add() {
this.$router.push({path: '/sampling_plan/sampling_plan_add', query: {title: '抽样计划添加'}})
},
_longtapHandler() {
this.showCheck = true
},
_hideCheck() {
this.showCheck = false
this.checkListValue = []
},
_checkAll() {
if (this.checkAll) {
this.$refs.checkboxGroup.toggleAll();
} else {
this.$refs.checkboxGroup.toggleAll(true);
}
},
_tapItem(item) {
if (this.showCheck) {
if (this.checkListValue.indexOf(item.id) === -1) {
this.checkListValue.push(item.id);
} else {
this.checkListValue.splice(this.checkListValue.indexOf(item.id), 1);
}
} else {
this._edit(item)
// if (item.testedType === 1) {
// this.$router.push({path: '/sampling_plan/sampling_plan_detail_net', query: {id: item.id}})
// } else if (item.testedType === 0) {
// this.$router.push({path: '/sampling_plan/sampling_plan_detail', query: {id: item.id}})
// } else {
// this.$router.push({
// path: '/sampling_plan/sampling_plan_detail_agriculture',
// query: {id: item.id}
// })
// }
}
},
_edit(item) {
this.$router.push({path: '/sampling_plan/sampling_plan_add', query: {id: item.id, title: '抽样计划编辑'}})
},
_peopleManage(item) {
this.$router.push({path: '/sampling_plan/sampler_checked', query: {planId: item.id}})
},
_locManage(item) {
this.$router.push({path: '/sampling_plan/loc_checked', query: {planId: item.id}})
},
_maintain(item) {
this.$router.push({path: '/sampling_plan/maintain', query: {planId: item.id}})
},
_del(ids) {
if (ids.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
this._delOk(ids)
}
},
_delOk: async function (ids) {
let result = await samplingPlan.deleteByIds(ids)
if (result) {
this.$toast('操作成功!')
this._refresh()
}
},
_submit() {
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
// this._delOk(ids)
// todo 提交
}
},
_goFile(id) {
this.$router.push({path: '/sampling_plan/file', query: {planId: id}})
}
}
}
</script>
<style scoped>
......
<template>
<div>
<van-form @submit="onSubmit">
<van-field
v-model="formObj.name"
name="name"
label="计划名称"
placeholder="计划名称"
:rules="[{ required: true, message: '请填写计划名称'}]"
></van-field>
<van-field
v-model="formObj.planDate"
name="monitorDate"
label="计划日期"
placeholder="计划日期"
@click="_selectDate('formObj.planDate')"
></van-field>
<van-field
v-model="formObj.issuingUnit"
name="issuingUnit"
label="任务下达单位"
placeholder="任务下达单位"
></van-field>
<van-field
v-model="formObj.taskSource"
name="taskSource"
label="任务来源"
placeholder="任务来源"
></van-field>
<van-field
type="textarea"
v-model="formObj.product"
name="product"
label="产品"
placeholder="产品"
></van-field>
<van-field
v-model="formObj.standard"
name="standard"
label="抽查依据标准"
placeholder="抽查依据标准"
></van-field>
<van-field
v-model="formObj.finishDate"
name="finishDate"
label="完成时间"
placeholder="完成时间"
@click="_selectDate('formObj.finishDate')"
></van-field>
<van-field
type="number"
v-model="formObj.samplingQuantity"
name="samplingQuantity"
label="抽样数量"
placeholder="抽样数量"
></van-field>
<van-field
type="number"
v-model="formObj.testCost"
name="testCost"
label="检测费用"
placeholder="检测费用"
></van-field>
<van-field
v-model="formObj.announcementNo"
name="announcementNo"
label="公告号"
placeholder="公告号"
></van-field>
<van-field
v-model="formObj.announcementDate"
name="announcementDate"
label="公告日期"
placeholder="公告日期"
@click="_selectDate('formObj.announcementDate')"
></van-field>
<van-field
type="textarea"
v-model="formObj.remark"
name="remark"
label="备注"
placeholder="备注"
></van-field>
<div style="margin: 16px;">
<van-button round block type="info" native-type="submit">
保存
</van-button>
</div>
</van-form>
<van-popup v-model="showDatePicker" position="bottom"
:safe-area-inset-bottom="true"
:close-on-popstate="true">
<van-datetime-picker
type="date"
v-model="currentDate"
@confirm="_dateConfirm"
@cancel="showDatePicker = false"
></van-datetime-picker>
</van-popup>
</div>
</template>
<script>
import {samplingPlan} from '../../api'
export default {
name: "SamplingPlanAdd",
data() {
return {
showDatePicker: false,
currentDate: new Date(),
selectDateType: '',
id: '',
formObj: {
name: '',
planDate: '',
issuingUnit: '',
taskSource: '',
product: '',
standard: '',
finishDate: '',
samplingQuantity: '',
testCost: 0,
announcementNo: '',
announcementDate: '',
remark: ''
}
}
},
mounted() {
this._open()
},
methods: {
_open() {
if (this.$route.query.id) {//编辑
this.id = this.$route.query.id
this._getData()
} else {
this.id = ''
}
},
_getData: async function () {
let result = await samplingPlan.getById(this.id)
if (result) {
for (let key in this.formObj) {
if (result[key]) {
if (key === 'planDate'||key === 'finishDate'||key === 'announcementDate') {
this.formObj[key] = this.$dateformat(result[key], 'yyyy-mm-dd')
} else {
this.formObj[key] = result[key]
}
}
}
}
},
onSubmit(res) {
if (this.id) {
this._editSave(this.$serializeForm(res))
} else {
this._addSave(this.$serializeForm(res))
}
},
_editSave: async function (res) {
let result = await samplingPlan.edit({id: this.id, obj: res})
if (result) {
this.$toast('编辑成功!')
this.$router.go(-1)
}
},
_addSave: async function (res) {
let result = await samplingPlan.add(res)
if (result) {
this.$toast('添加成功!')
this.$router.go(-1)
}
},
_selectDate(type) {
this.selectDateType = type
this.showDatePicker = true
},
_dateConfirm(date) {
switch (this.selectDateType) {
case 'formObj.planDate':
this.formObj.planDate = this.$dateformat(date, 'yyyy-mm-dd')
break
case 'formObj.finishDate':
this.formObj.finishDate = this.$dateformat(date, 'yyyy-mm-dd')
break
case 'formObj.announcementDate':
this.formObj.announcementDate = this.$dateformat(date, 'yyyy-mm-dd')
break
}
this.showDatePicker = false
},
}
}
</script>
<style scoped>
</style>
......@@ -28,6 +28,9 @@
</template>
<script>
/**
* 抽样任务-人员双随机-手动添加
*/
import {sampler, samplingPlan} from '../../../api'
export default {
......
import SamplingPlan from '@/page/sampling-plan/SamplingPlan.vue'
import SamplingPlanAdd from '@/page/sampling-plan/SamplingPlanAdd.vue'
import Maintain from '@/page/sampling-plan/Maintain.vue'
import RandomCreate from '@/page/sampling-plan/RandomCreate.vue'
import SamplingPlanAdd from '@/page/sampling-plan/add/SamplingPlanAdd.vue'
import SamplerChecked from '@/page/sampling-plan/sampler/SamplerChecked.vue'
// import SamplerChecked from '@/page/sampling-plan/sampler/SamplerChecked.vue'
import SelectSampler from '@/page/sampling-plan/sampler/SelectSampler.vue'
import CreateSampler from '@/page/sampling-plan/sampler/CreateSampler.vue'
// import CreateSampler from '@/page/sampling-plan/sampler/CreateSampler.vue'
import LocChecked from '@/page/sampling-plan/loc/LocChecked.vue'
import SelectLoc from '@/page/sampling-plan/loc/SelectLoc.vue'
import CreateLoc from '@/page/sampling-plan/loc/CreateLoc.vue'
import LocAdd from '@/page/sampling-plan/loc/LocAdd.vue'
// import SelectLoc from '@/page/sampling-plan/loc/SelectLoc.vue'
// import CreateLoc from '@/page/sampling-plan/loc/CreateLoc.vue'
// import LocAdd from '@/page/sampling-plan/loc/LocAdd.vue'
import File from '@/page/sampling-plan/file/File.vue'
import FileDownLoad from '@/page/sampling-plan/file/FileDownLoad.vue'
......@@ -16,16 +18,18 @@ import FileUpload from '@/page/sampling-plan/file/FileUpload.vue'
export default [
{path: 'sampling_plan', component: SamplingPlan, meta: {title: '抽样计划', hideNavBar: true}},
{path: 'maintain', component: Maintain, meta: {title: '维护人员、地点'}},
{path: 'random_create', component: RandomCreate, meta: {title: '随机生成'}},
{path: 'sampling_plan_add', component: SamplingPlanAdd, meta: {customerNavBarTitle: true}},
{path: 'sampler_checked', component: SamplerChecked, meta: {title: '管理抽样人员'}},
// {path: 'sampler_checked', component: SamplerChecked, meta: {title: '管理抽样人员'}},
{path: 'select_sampler', component: SelectSampler, meta: {title: '选择抽样人员'}},
{path: 'create_sampler', component: CreateSampler, meta: {title: '生成抽样人员'}},
// {path: 'create_sampler', component: CreateSampler, meta: {title: '生成抽样人员'}},
{path: 'loc_checked', component: LocChecked, meta: {title: '管理抽样地点'}},
{path: 'select_loc', component: SelectLoc, meta: {title: '选择抽样地点'}},
{path: 'create_loc', component: CreateLoc, meta: {title: '生成抽样地点'}},
{path: 'loc_add', component: LocAdd, meta: {title: '添加地点'}},
// {path: 'select_loc', component: SelectLoc, meta: {title: '选择抽样地点'}},
// {path: 'create_loc', component: CreateLoc, meta: {title: '生成抽样地点'}},
// {path: 'loc_add', component: LocAdd, meta: {title: '添加地点'}},
{path: 'file', component: File, meta: {title: '附件'}},
{path: 'file_upload', component: FileUpload, meta: {title: '添加附件'}},
......
......@@ -287,3 +287,8 @@ html, body, #app, .main-content-con {
color: @text-color-white;
}
}
.van-field__control--custom{
flex-wrap: wrap;
}
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