feat: 更新一次,添加一个table
This commit is contained in:
@ -8,7 +8,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form_cnt">
|
<div class="form_cnt">
|
||||||
<FormMessage v-model="listQuery" :formList="formData" ref="elform" :rules="rules" />
|
<FormMessage v-model="listQuery" :formList="formData" ref="elform" :rules="rules">
|
||||||
|
<template #bmList>
|
||||||
|
<div class="table-box">
|
||||||
|
<el-table :data="tableList" border style="width: 100%">
|
||||||
|
<el-table-column prop="ypbmmc" label="部门" width="150" align="center" />
|
||||||
|
<el-table-column label="研判素材" width="280" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.scyq" :disabled="!isShiQingBaoZhongXin" placeholder="请输入研判素材" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="附件" width="200" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<UploadFile v-model="row.fj" :disabled="!isShiQingBaoZhongXin" :limit="1" :isImg="false"
|
||||||
|
:isAll="true" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="wcqk" label="完成状态" width="120" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.wcqk === '02' ? 'success' : 'warning'">
|
||||||
|
{{ row.wcqk == '01' ? '准备中' : '已完成' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="120" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button type="text" size="small" @click="updateStatus(row)"
|
||||||
|
:disabled="isShiQingBaoZhongXin || (row.cjrsfzh && row.cjrsfzh != deptCode)">
|
||||||
|
修改状态
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</FormMessage>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <ChooseUser v-model="chooseUserVisible" @choosedUsers="handleUserSelected" :roleIds="roleIds" :Single="false" /> -->
|
<!-- <ChooseUser v-model="chooseUserVisible" @choosedUsers="handleUserSelected" :roleIds="roleIds" :Single="false" /> -->
|
||||||
@ -18,8 +52,10 @@
|
|||||||
import FormMessage from "@/components/aboutTable/FormMessage.vue";
|
import FormMessage from "@/components/aboutTable/FormMessage.vue";
|
||||||
import UploadFile from "@/components/MyComponents/Upload/index.vue";
|
import UploadFile from "@/components/MyComponents/Upload/index.vue";
|
||||||
// import ChooseUser from "@/components/ChooseList/ChooseUser/index.vue"
|
// import ChooseUser from "@/components/ChooseList/ChooseUser/index.vue"
|
||||||
import { ref, defineExpose, reactive, defineEmits, getCurrentInstance, watch } from "vue";
|
import { ref, defineExpose, reactive, defineEmits, getCurrentInstance, watch, computed } from "vue";
|
||||||
import { sjzlAddEntity, sjzlEditEntity, sjzlGetInfo } from '@//api/yj.js'
|
import { sjzlAddEntity, sjzlEditEntity, sjzlGetInfo, sjzlPerfectlnfo } from '@//api/yj.js'
|
||||||
|
import { getItem } from '@//utils/storage.js'
|
||||||
|
|
||||||
const emit = defineEmits(["updateDate", "getList"]);
|
const emit = defineEmits(["updateDate", "getList"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dict: Object
|
dict: Object
|
||||||
@ -30,11 +66,23 @@ const dialogForm = ref(false); //弹窗
|
|||||||
const formData = ref([
|
const formData = ref([
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
const { deptBizType, deptLevel, deptCode } = getItem('deptId')[0]
|
||||||
|
/** 登录人 */
|
||||||
|
const sfzh = getItem('idEntityCard')
|
||||||
|
/** 是否市情报指挥中心 */
|
||||||
|
const isShiQingBaoZhongXin = computed(() => {
|
||||||
|
|
||||||
|
const Jb = deptLevel[0] == '2' ? '01' : deptLevel[0] == '3' ? '02' : '03'
|
||||||
|
return deptBizType == '23' && Jb == '01'
|
||||||
|
})
|
||||||
const listQuery = ref({}); //表单
|
const listQuery = ref({}); //表单
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const elform = ref();
|
const elform = ref();
|
||||||
const title = ref("");
|
const title = ref("");
|
||||||
|
const tableList = ref([])
|
||||||
|
// const detailObj = ref({})
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
|
// 可以在这里添加表单验证规则
|
||||||
});
|
});
|
||||||
watch(() => props.dict, (val) => {
|
watch(() => props.dict, (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
@ -45,9 +93,45 @@ watch(() => props.dict, (val) => {
|
|||||||
{ label: "研判方式", prop: "ypfs", type: "radio", options: props.dict.D_BZ_YPFS, width: '48%' },
|
{ label: "研判方式", prop: "ypfs", type: "radio", options: props.dict.D_BZ_YPFS, width: '48%' },
|
||||||
{ label: "参与研判部门", prop: "jsdxBmDm", type: "department", multiple: true, depMc: 'jsdxBmMc', width: '48%' },
|
{ label: "参与研判部门", prop: "jsdxBmDm", type: "department", multiple: true, depMc: 'jsdxBmMc', width: '48%' },
|
||||||
{ label: "研判要求", prop: "ypyq", type: "textarea", width: '100%' },
|
{ label: "研判要求", prop: "ypyq", type: "textarea", width: '100%' },
|
||||||
|
{ label: "列表", prop: "bmList", type: "slot", width: '100%' },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
function getFjArr(fj) {
|
||||||
|
if (typeof fj !== 'string' || !fj) return []
|
||||||
|
let fjArr = []
|
||||||
|
try {
|
||||||
|
fjArr = JSON.parse(fj)
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error: ', error);
|
||||||
|
}
|
||||||
|
return fjArr
|
||||||
|
}
|
||||||
|
watch(() => listQuery.value.jsdxBmDm, (val) => {
|
||||||
|
/** @type {Array<{ypbmdm: string, ypbmmc: string, scyq: string, fj: Array, wcqk: string}>} 参与研判部门数据数组 */
|
||||||
|
const arr = Array.isArray(val) ? val : []
|
||||||
|
const cyypList = Array.isArray(listQuery.value.cyypList) ? listQuery.value.cyypList : []
|
||||||
|
|
||||||
|
tableList.value = arr.map((item, i) => {
|
||||||
|
/** 找原来的对象 */
|
||||||
|
const curr = cyypList.find(item2 => item2.ypbmdm == item) || {}
|
||||||
|
/** 是否是新增 */
|
||||||
|
const isAddForm = !listQuery.value.id
|
||||||
|
return {
|
||||||
|
// id: null,
|
||||||
|
// sjzlid: null, // 研判数据整理ID
|
||||||
|
/** 部门代码 */
|
||||||
|
ypbmdm: item,
|
||||||
|
ypbmmc: listQuery.value.jsdxBmMc[i],
|
||||||
|
/** 素材要求 */
|
||||||
|
scyq: isAddForm ? '' : curr.scyq,
|
||||||
|
fj: isAddForm ? [] : getFjArr(curr.fj),
|
||||||
|
/** 完成情况(01 准备中、02 已完成)*/
|
||||||
|
wcqk: isAddForm ? '01' : curr.wcqk || '01'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
const init = (type, row, wjlb) => {
|
const init = (type, row, wjlb) => {
|
||||||
dialogForm.value = true;
|
dialogForm.value = true;
|
||||||
@ -57,28 +141,56 @@ const init = (type, row, wjlb) => {
|
|||||||
// 根据id查询详情
|
// 根据id查询详情
|
||||||
const getDataById = (id) => {
|
const getDataById = (id) => {
|
||||||
sjzlGetInfo(id).then((res) => {
|
sjzlGetInfo(id).then((res) => {
|
||||||
listQuery.value = res;
|
listQuery.value = res || {};
|
||||||
listQuery.value.jsdxBmDm = res.cyypList.map(item => {
|
const cyypList = Array.isArray(res.cyypList) ? res.cyypList : []
|
||||||
|
listQuery.value.jsdxBmDm = cyypList.map(item => {
|
||||||
return item.ypbmdm
|
return item.ypbmdm
|
||||||
})
|
})
|
||||||
listQuery.value.jsdxBmMc = res.cyypList.map(item => {
|
listQuery.value.jsdxBmMc = cyypList.map(item => {
|
||||||
return item.ypbmmc
|
return item.ypbmmc
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
function getFjString(arr) {
|
||||||
|
arr = Array.isArray(arr) ? arr : []
|
||||||
|
return JSON.stringify(arr)
|
||||||
|
}
|
||||||
|
/**获取下发部门数据 */
|
||||||
|
const getXfbmList = () => {
|
||||||
|
const cyypList = Array.isArray(listQuery.value.cyypList) ? listQuery.value.cyypList : []
|
||||||
|
|
||||||
|
return tableList.value.map((item, i) => {
|
||||||
|
|
||||||
|
/** 找原来的对象 */
|
||||||
|
const curr = cyypList.find(item => item.ypbmdm == item.ypbmdm) || {}
|
||||||
|
return {
|
||||||
|
id: curr.id || null,
|
||||||
|
sjzlid: curr.sjzlid || null, // 研判数据整理ID
|
||||||
|
ypbmdm: item.ypbmdm,
|
||||||
|
ypbmmc: listQuery.value.jsdxBmMc[i],
|
||||||
|
/** 素材要求 */
|
||||||
|
scyq: item.scyq,
|
||||||
|
fj: getFjString(item.fj),
|
||||||
|
/** 完成情况(01 准备中、02 已完成)*/
|
||||||
|
wcqk: item.wcqk
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
// 提交
|
// 提交
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
elform.value.submit(async (data) => {
|
elform.value.submit(async (data) => {
|
||||||
|
const xfbmList = getXfbmList()
|
||||||
let params = {
|
let params = {
|
||||||
...listQuery.value,
|
...listQuery.value,
|
||||||
cyypList: listQuery.value.jsdxBmDm.map((item, index) => {
|
cyypList: xfbmList,
|
||||||
return {
|
// cyypList: listQuery.value.jsdxBmDm.map((item, index) => {
|
||||||
ypbmdm: item,
|
// return {
|
||||||
ypbmmc: listQuery.value.jsdxBmMc[index],
|
// ypbmdm: item,
|
||||||
ypcylx: '01'
|
// ypbmmc: listQuery.value.jsdxBmMc[index],
|
||||||
}
|
// ypcylx: '01'
|
||||||
})
|
// }
|
||||||
|
// })
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@ -97,7 +209,7 @@ const submit = () => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -110,6 +222,28 @@ const submit = () => {
|
|||||||
// userList.value = val
|
// userList.value = val
|
||||||
// listQuery.value.jsrxm = val.map(item => item.userName).join(',')
|
// listQuery.value.jsrxm = val.map(item => item.userName).join(',')
|
||||||
// }
|
// }
|
||||||
|
// 修改状态
|
||||||
|
const updateStatus = (row) => {
|
||||||
|
proxy.$confirm('确认修改状态?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
// 调用xx接口,这里需要根据实际接口调整
|
||||||
|
// 例如:updateStatusApi(row.id).then(...)
|
||||||
|
if (row.wcqk == '01') {
|
||||||
|
row.wcqk = '02'
|
||||||
|
} else {
|
||||||
|
row.wcqk = '01'
|
||||||
|
}
|
||||||
|
proxy.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '修改成功'
|
||||||
|
});
|
||||||
|
// 更新本地状态
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
// 关闭
|
// 关闭
|
||||||
const close = () => {
|
const close = () => {
|
||||||
listQuery.value = {};
|
listQuery.value = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user