|
@@ -25,9 +25,9 @@
|
|
|
|
|
|
<el-col :span="24">
|
|
|
<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 @click="delSubmit">删除</el-button>
|
|
|
+ <el-button @click="delSubmit" v-if="isUpdateAction">删除</el-button>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -45,15 +45,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import {reactive,ref,toRaw,onMounted} from 'vue'
|
|
|
+ import {reactive,ref,toRaw,onMounted,watch} from 'vue'
|
|
|
import stationAPI from "../../api/station.js"
|
|
|
import {ElMessageBox,ElMessage} from 'element-plus'
|
|
|
import utils from "../../utils/utils.js"
|
|
|
+ import {useHomeStore} from "@/store/home.js"
|
|
|
|
|
|
const props=defineProps({
|
|
|
orgId:String
|
|
|
})
|
|
|
|
|
|
+ const store = useHomeStore()
|
|
|
+
|
|
|
const orgTreeNodes = ref([])
|
|
|
|
|
|
const orgNodeProps = {
|
|
@@ -104,6 +107,32 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ const isUpdateAction=ref(true)
|
|
|
+ const initAdd=()=>{
|
|
|
+ isUpdateAction.value=false
|
|
|
+ }
|
|
|
+ const initUpdate=async (id)=>{
|
|
|
+ isUpdateAction.value=true
|
|
|
+
|
|
|
+ stationAPI.getOrg(id).then(resp=>{
|
|
|
+ if(resp.code==0){
|
|
|
+ let {orgId,orgName,superId,superName,displayNum,multiPatrolTemp}=resp.data
|
|
|
+
|
|
|
+ Object.assign(formModel,{orgId,orgName,superId,superName,displayNum,multiPatrolTemp})
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log('get org err:'+err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ watch(
|
|
|
+ ()=>props.orgId,
|
|
|
+ (newVal, oldVal)=>{
|
|
|
+ newVal?initUpdate(newVal):initAdd()
|
|
|
+ }
|
|
|
+ ,{ immediate: true }
|
|
|
+ )
|
|
|
+
|
|
|
const saveSubmit=()=>{
|
|
|
formcomp.value.validate((valid) => {
|
|
|
if(!valid){
|
|
@@ -116,7 +145,7 @@
|
|
|
return
|
|
|
}
|
|
|
ElMessage.success('操作成功')
|
|
|
-
|
|
|
+ store.refreshTreeTime=(new Date()).getTime()
|
|
|
|
|
|
}).catch(err=>{
|
|
|
ElMessage.error(err||'操作失败')
|
|
@@ -136,8 +165,9 @@
|
|
|
return
|
|
|
}
|
|
|
ElMessage.success('操作成功')
|
|
|
- //clearForm()
|
|
|
-
|
|
|
+ clearForm()
|
|
|
+ //initUpdate(resp.data)
|
|
|
+ store.refreshTreeTime=(new Date()).getTime()
|
|
|
|
|
|
}).catch(err=>{
|
|
|
ElMessage.error(err||'操作失败')
|
|
@@ -166,7 +196,7 @@
|
|
|
}
|
|
|
ElMessage.success('操作成功')
|
|
|
clearForm()
|
|
|
-
|
|
|
+ store.refreshTreeTime=(new Date()).getTime()
|
|
|
|
|
|
}).catch(err=>{
|
|
|
ElMessage.error(err||'操作失败')
|