|
@@ -2,6 +2,11 @@
|
|
<div class="edit-page">
|
|
<div class="edit-page">
|
|
<el-form :model="formModel" ref="formcomp" label-position="right" label-width="100" :inline="false" :rules="rules" :inline-message="true">
|
|
<el-form :model="formModel" ref="formcomp" label-position="right" label-width="100" :inline="false" :rules="rules" :inline-message="true">
|
|
<el-row :gutter="20">
|
|
<el-row :gutter="20">
|
|
|
|
+ <el-col :sm="24" :md="12" :lg="8">
|
|
|
|
+ <el-form-item label="所属井站">
|
|
|
|
+ <el-input v-model="formModel.belongOrgName" autocomplete="off" class="edit-form-item" disabled/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
<el-col :sm="24" :md="12" :lg="8">
|
|
<el-col :sm="24" :md="12" :lg="8">
|
|
<el-form-item label="井名" prop="wellName">
|
|
<el-form-item label="井名" prop="wellName">
|
|
<el-input v-model="formModel.wellName" autocomplete="off" placeholder="请输入井名" class="edit-form-item" clearable/>
|
|
<el-input v-model="formModel.wellName" autocomplete="off" placeholder="请输入井名" class="edit-form-item" clearable/>
|
|
@@ -46,6 +51,24 @@
|
|
<el-input v-model="formModel.patrolStdTemp" autocomplete="off" placeholder="请选择巡查模板" class="edit-form-item" clearable/>
|
|
<el-input v-model="formModel.patrolStdTemp" autocomplete="off" placeholder="请选择巡查模板" class="edit-form-item" clearable/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
+ <el-col :sm="24" :md="12" :lg="8">
|
|
|
|
+ <el-form-item label="采集设备">
|
|
|
|
+ <el-select v-model="formModel.gatherDevice" placeholder="请选择采集设备" style="width:100%;"
|
|
|
|
+ multiple
|
|
|
|
+ collapse-tags
|
|
|
|
+ collapse-tags-tooltip
|
|
|
|
+ clearable
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in gatherDevices" :key="item.deviceCode" :label="item.deviceCode" :value="item.deviceCode"/>
|
|
|
|
+ </el-select>
|
|
|
|
+
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :sm="24" :md="12" :lg="8">
|
|
|
|
+ <el-form-item label="显示序号">
|
|
|
|
+ <el-input-number v-model="formModel.displayNum" :min="1" :max="10000" style="width:100%"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
<el-form-item label="地理位置">
|
|
<el-form-item label="地理位置">
|
|
<el-input v-model="formModel.locate" autocomplete="off" placeholder="请输入地理位置" class="edit-form-item" clearable/>
|
|
<el-input v-model="formModel.locate" autocomplete="off" placeholder="请输入地理位置" class="edit-form-item" clearable/>
|
|
@@ -53,9 +76,9 @@
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
<el-form-item label=" ">
|
|
<el-form-item label=" ">
|
|
- <el-button type="primary" @click="saveSubmit">保存</el-button>
|
|
|
|
|
|
+ <el-button type="primary" @click="saveSubmit" v-if="isUpdateAction">保存</el-button>
|
|
<el-button type="success" @click="addSubmit">新增</el-button>
|
|
<el-button type="success" @click="addSubmit">新增</el-button>
|
|
- <el-button @click="delSubmit">删除</el-button>
|
|
|
|
|
|
+ <el-button @click="delSubmit" v-if="isUpdateAction">删除</el-button>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
@@ -73,14 +96,16 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
- import {reactive,ref,toRaw,onMounted} from 'vue'
|
|
|
|
- import paramMgrAPI from "../../api/paramMgr.js"
|
|
|
|
|
|
+ import {reactive,ref,toRaw,onMounted,watch,useAttrs } from 'vue'
|
|
|
|
+ import stationAPI from "../../api/station.js"
|
|
import {ElMessageBox,ElMessage} from 'element-plus'
|
|
import {ElMessageBox,ElMessage} from 'element-plus'
|
|
|
|
|
|
const props=defineProps({
|
|
const props=defineProps({
|
|
- record:Object
|
|
|
|
|
|
+ wellId:String
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ const attrs = useAttrs()
|
|
|
|
+
|
|
const formModel = reactive({
|
|
const formModel = reactive({
|
|
wellId:'',
|
|
wellId:'',
|
|
wellName: '',
|
|
wellName: '',
|
|
@@ -89,30 +114,175 @@
|
|
lng:'',
|
|
lng:'',
|
|
lat:'',
|
|
lat:'',
|
|
locate:'',
|
|
locate:'',
|
|
- patrolStdTemp:''
|
|
|
|
|
|
+ patrolStdTemp:'',
|
|
|
|
+ orgId:'',
|
|
|
|
+ belongOrgName:'',
|
|
|
|
+ gatherDevice:'',
|
|
|
|
+ displayNum:1
|
|
})
|
|
})
|
|
|
|
|
|
const formcomp = ref(null);
|
|
const formcomp = ref(null);
|
|
|
|
|
|
const rules =reactive({
|
|
const rules =reactive({
|
|
wellName:[
|
|
wellName:[
|
|
- {required:true,message:'参数名还未填写',trigger:'blur'},
|
|
|
|
|
|
+ {required:true,message:'井名还未填写',trigger:'blur'},
|
|
{ min: 1, max: 20, message: '参数名长度应该为1-20', trigger: 'blur' }
|
|
{ min: 1, max: 20, message: '参数名长度应该为1-20', trigger: 'blur' }
|
|
],
|
|
],
|
|
patrolStdTemp:[
|
|
patrolStdTemp:[
|
|
- {required:true,message:'参数编码还未填写',trigger:'blur'},
|
|
|
|
|
|
+ {required:true,message:'巡查标准模板还未选择',trigger:'blur'},
|
|
]
|
|
]
|
|
})
|
|
})
|
|
|
|
|
|
const wellSortOpts=ref([])
|
|
const wellSortOpts=ref([])
|
|
const wellTypeOpts=ref([])
|
|
const wellTypeOpts=ref([])
|
|
|
|
+ const gatherDevices=ref([])
|
|
|
|
|
|
|
|
+ let initFormDone=false
|
|
|
|
|
|
- const saveSubmit=()=>{}
|
|
|
|
|
|
+ const initForm=async ()=>{
|
|
|
|
+ let codeMap={'4028cd478712d076018712d1e45d0001':wellSortOpts,'4028cd478712d076018712d22fd60002':wellTypeOpts}
|
|
|
|
+ let superIds=(Object.keys(codeMap)).join(",")
|
|
|
|
+
|
|
|
|
+ try{
|
|
|
|
+ let resp=await stationAPI.loadSortCode({superIds})
|
|
|
|
+ if(resp.code!=0){
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for(let sort in resp.data){
|
|
|
|
+ codeMap[sort].value=resp.data[sort]
|
|
|
|
+ }
|
|
|
|
+ initFormDone=true
|
|
|
|
+
|
|
|
|
+ return Promise.resolve('ok')
|
|
|
|
+ }
|
|
|
|
+ catch(err){
|
|
|
|
+ return Promise.reject('err')
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- const addSubmit=()=>{}
|
|
|
|
|
|
+ const isUpdateAction=ref(true)
|
|
|
|
|
|
- const delSubmit=()=>{}
|
|
|
|
|
|
+ const initAdd=()=>{
|
|
|
|
+ isUpdateAction.value=false
|
|
|
|
+ if(!initFormDone){
|
|
|
|
+ initForm()
|
|
|
|
+ }
|
|
|
|
+ formModel.orgId=attrs['orgId']
|
|
|
|
+ formModel.belongOrgName=attrs['orgName']
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const initUpdate=async (id)=>{
|
|
|
|
+ isUpdateAction.value=true
|
|
|
|
+ if(!initFormDone){
|
|
|
|
+ console.log('start init form')
|
|
|
|
+ try{
|
|
|
|
+ await initForm()
|
|
|
|
+ }
|
|
|
|
+ catch(err){
|
|
|
|
+ console.log('initForm error')
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ stationAPI.getWell(id).then(resp=>{
|
|
|
|
+ console.log(resp)
|
|
|
|
+ if(resp.code==0){
|
|
|
|
+ let {wellId,wellName,wellSort,wellType,lng,lat,locate,patrolStdTemp,orgId,belongOrgName,gatherDevice,displayNum}=resp.data
|
|
|
|
+
|
|
|
|
+ Object.assign(formModel,{wellId,wellName,wellSort,wellType,lng,lat,locate,patrolStdTemp,orgId,belongOrgName,gatherDevice,displayNum})
|
|
|
|
+ }
|
|
|
|
+ }).catch(err=>{
|
|
|
|
+ console.log('get well err:'+err)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ watch(
|
|
|
|
+ ()=>props.wellId,
|
|
|
|
+ (newVal, oldVal)=>{
|
|
|
|
+ console.log(newVal+":"+oldVal)
|
|
|
|
+ newVal?initUpdate(newVal):initAdd()
|
|
|
|
+ }
|
|
|
|
+ ,{ immediate: true }
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const saveSubmit=()=>{
|
|
|
|
+ formcomp.value.validate((valid) => {
|
|
|
|
+ if(!valid){
|
|
|
|
+ ElMessage.error("请按要求填写数据");
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ stationAPI.saveWell(toRaw(formModel)).then(resp=>{
|
|
|
|
+ if(resp.code!=0){
|
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ElMessage.success('操作成功')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(err=>{
|
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const addSubmit=()=>{
|
|
|
|
+ formcomp.value.validate((valid) => {
|
|
|
|
+ if(!valid){
|
|
|
|
+ ElMessage.error("请按要求填写数据");
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ stationAPI.addWell(toRaw(formModel)).then(resp=>{
|
|
|
|
+ if(resp.code!=0){
|
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ElMessage.success('操作成功')
|
|
|
|
+ //clearForm()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(err=>{
|
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const delSubmit=()=>{
|
|
|
|
+ if(!formModel.wellId){
|
|
|
|
+ ElMessage.error("请先选择一口井,再继续");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ '确定要删除吗?',
|
|
|
|
+ '操作确认',
|
|
|
|
+ {
|
|
|
|
+ confirmButtonText:'确定',
|
|
|
|
+ cancelButtonText:'取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }
|
|
|
|
+ ).then(()=>{
|
|
|
|
+ stationAPI.delWell({wellId:formModel.wellId}).then(resp=>{
|
|
|
|
+ if(resp.code!=0){
|
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ElMessage.success('操作成功')
|
|
|
|
+ clearForm()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(err=>{
|
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ }).catch(()=>{
|
|
|
|
+ console.log('cancel del')
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const clearForm=()=>{
|
|
|
|
+ let [wellId,wellName,wellSort,wellType,lng,lat,locate,orgId,belongOrgName,gatherDevice,patrolStdTemp,displayNum]=[null,null,null,null,null,null,null,null,null,null,null,1]
|
|
|
|
+ Object.assign(formModel,{wellId,wellName,wellSort,wellType,lng,lat,locate,orgId,belongOrgName,gatherDevice,patrolStdTemp,displayNum})
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
</script>
|
|
</script>
|