数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

200 lines
5.6 KiB

<!--
@ 作者: 鲁智强
@ 时间: 2023-09-19 09:13:14
@ 备注:
-->
<script lang='ts' setup>
import {ref,reactive,onMounted} from 'vue'
import { organdpost,posttarget,set_posttarget } from '@/api/opk/api'
import { addPostCont,tarlist,deltarget } from '@/api/opk/api'
import { editPostCont } from '@/api/opk/pulic/api'
import { departmentprogramme,edit_depart } from '@/api/opk/news/api'
import { ge_copy } from '@/api/opk/zxy/news/api'
import { formItemValidateStates, TableV2SortOrder } from 'element-plus';
import { getDictFormData } from '@/api/dict'
import Dialog from './dialog.vue'
import Dialoglog from './dialoglog.vue'
// eslint-disable-next-line vue/require-prop-types
const { addShow, title } = defineProps(['addShow', 'title'])
const data = reactive({
formInline:{
region:'',
},
title:"",
addPostBox: false,
edPostBox:false,
})
const orgTreeProps ={
label: 'name',
children:'child'
}
const orgTreeProp ={
label: 'title',
children:'childen'
}
const formdat = {
someProp:"",
}
const total =ref(0)
let rowInfo = ref<any>({})
const postIds = ref<number[]>([])
const tableData = ref<any>([]);
const tables = ref<any>([]);
// 获取侧栏数据
function jjjs(){
addPostCont("/hrapi/org/govthree","post")
.then(data => {
tableData.value = data.data[3].child[14].child;
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
jjjs()
function editPost(){
editPostCont({})
.then(data => {
tables.value = data.data.list;
})
}
editPost()
const table = ref<any>([])
const formdate = reactive({
page:0,
pagesize:20,
name:"",
dimension:"",
attribute:"",
orgidlist:[]as String[],
type:"",
value1:"2023",
})
// 获取数据
const tableq = ref([])
const postt = ()=>{
const ass = new Date(formdate.value1);
const qwe = ass.getFullYear();
const zjr = qwe.toString();
departmentprogramme({orgid:formdate.orgidlist,year:zjr,version:formdate.name})
.then(data => {
tableq.value = data.data;
total.value = data.data.count;
})
}
// 新增数据
const addtableData = ()=>{
data.addPostBox = true;
}
// 添加行
const addRow = (val:any)=> {
tableData.value.push(val);
}
// 编辑行
const editRow = (val:any)=> {
let index =tableData.value.findIndex(
(item:any) => item.id === val.id
);
tableData.value.splice(index, 1, val);
}
// 关闭弹窗
const closeDetail = ()=>{
data.addPostBox = false;
}
// 删除数据
const handleDel = (val:any) => {
const dictTypeIds = [val.outID || postIds.value].join(",");
let dictTypeIdAry = dictTypeIds.split(",")
ElMessageBox.confirm("你确定删除这条信息吗?", "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
const add = val.key.toString()
handleSure(val)
console.log(val.id)
edit_depart({id:add,state:3,istrue:2}).then(()=>
ElMessage.success("删除成功"))
})
postt()
};
const handleSure = (val:any)=> {
const index = tableData.value.findIndex((item:any) => item.id === val.id);
if(index!=-1){
tableData.value.splice(index, 1);
}
}
const resetChecked=()=> {
formdate.orgidlist = []
postt()
}
const handle=(data:any)=>{
formdate.orgidlist = data.id.toString()
postt()
}
const handleErd=(val:any)=>{
data.edPostBox=true;
rowInfo.value=val;
}
//重置
const zjr = ()=>{
formdate.orgidlist = "";
}
onMounted(()=>{
jjjs()
postt()
})
</script>
<template>
<div>
<el-container style="width: 100%">
<diV>
<el-button type="primary" style="width: 100%" @click="resetChecked">全选</el-button>
<el-tree ref="orgTreeRef" v-model="formdate.orgidlist" node-key="id" class="orgTree" :data="tableData" :props="orgTreeProps" :default-expand-all="false" @node-click="handle"/>
</div>
<el-col :span="22">
<div class="horizontal-controls">
<el-form-item label="方案版本号">
<el-input v-model="formdate.name" placeholder="请输入方案版本号" clearable/>
</el-form-item>
<el-form-item>
<span class="demonstration">年度</span>
<el-date-picker v-model="formdate.value1" type="year"/>
</el-form-item>
<el-button @click="postt">查询</el-button>
<el-button class="new_btn" type="success" @click="addtableData">新增</el-button>
</div>
<el-table :data="tableq" border style="width: 100%">
<el-table-column prop="deaprtname" label="部门"/>
<el-table-column prop="year" label="年"/>
<el-table-column prop="key" label="版本号"/>
<el-table-column prop="time" label="时间" />
<el-table-column prop="" label="状态" width="70">
<template #default="scope">
<el-switch v-model="scope.row.status" />
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200">
<template #default="{ row }">
<el-button type="success" link @click="handleErd(row)">复制</el-button>
<el-button type="danger" link @click="handleDel(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-container>
<pagination v-if="total > 0" v-model:page="formdate.page" v-model:pagesize="formdate.pagesize" :total="total" @click="postt"/>
<Dialog v-if="data.addPostBox" v-model="data.addPostBox" :title="title" :array-num="tableData.length" @add-row="addRow" @edit-row="editRow"></Dialog>
<Dialoglog v-if="data.edPostBox" v-model="data.edPostBox" :title="title" :row-info="rowInfo" :array-num="tableData.length" @add-row="addRow" @edit-row="editRow"></Dialoglog>
</div>
</template>
<style lang='scss' scoped>
.horizontal-controls {
display: flex;
float: left;
}
/* 可以根据需要调整样式 */
</style>