Browse Source

修改

master
yangzhou-cyber 3 years ago
parent
commit
cd920e30b8
9 changed files with 447 additions and 142 deletions
  1. +2
    -1
      src/store/getters.js
  2. +35
    -15
      src/store/modules/base.js
  3. +147
    -44
      src/utils/mixin.js
  4. +100
    -29
      src/views/assessingTarget/basicTarget.vue
  5. +21
    -4
      src/views/assessingTarget/constraint.vue
  6. +27
    -4
      src/views/assessingTarget/reward.vue
  7. +58
    -19
      src/views/assessingTarget/search.vue
  8. +33
    -17
      src/views/basicTable/category.vue
  9. +24
    -9
      src/views/basicTable/conventional.vue

+ 2
- 1
src/store/getters.js View File

theme: state => state.theme, theme: state => state.theme,
user: state => state.user, user: state => state.user,
quota1:state=>state.base.quota1, quota1:state=>state.base.quota1,
quota2:state=>state.base.quota2
quota2:state=>state.base.quota2,
department:state=>state.base.department
} }

+ 35
- 15
src/store/modules/base.js View File

import axios from "axios" import axios from "axios"

function formatDet(data) {
console.log
let format = function (pid) {
let arr = [];
data.forEach(item => {
if (item.pid == pid) {
item.children = format(item.id);
arr.push(item)
}
})
return arr;
}
return format(0)
}
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
} }
}, },
actions: { actions: {
getDepartment({ commit, state }) {
console.log('===========')
getDepartment({ commit, state }, data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (state.department.length > 0) { if (state.department.length > 0) {
resolve(state.department) resolve(state.department)
return; return;
} else { } else {
axios.get('dept/getDeptList').then(res=>{
console.log(res)
axios.get('dept/getDeptList/' + data).then(res => {
let data = res.data.data;
console.log(formatDet(data));
commit('SET_DEPARTMENT',formatDet(data));
return formatDet(data);
}).catch(()=>{
commit('SET_DEPARTMENT',[]);
return []
}) })
} }
}) })
}, },
getQuota1List({ commit }, data) { getQuota1List({ commit }, data) {
return new Promise((resolve) => { return new Promise((resolve) => {
axios.get('/quota/getQuota1List/'+data).then(res=>{
let data=res.data.data;
commit('SET_QUOTAL1',data);
axios.get('/quota/getQuota1List/' + data).then(res => {
let data = res.data.data;
commit('SET_QUOTAL1', data);
resolve(data) resolve(data)
}).catch(()=>{
commit('SET_QUOTAL1',[])
}).catch(() => {
commit('SET_QUOTAL1', [])
resolve([]); resolve([]);
}) })
}) })
}, },
getQuota2List({ commit}, data) {
getQuota2List({ commit }, data) {
return new Promise((resolve) => { return new Promise((resolve) => {
axios.get('/quota/getQuota2List/'+data).then(res=>{
let data=res.data.data;
commit('SET_QUOTAL2',data);
axios.get('/quota/getQuota2List/' + data).then(res => {
let data = res.data.data;
commit('SET_QUOTAL2', data);
resolve(data) resolve(data)
}).catch(()=>{
commit('SET_QUOTAL2',[])
}).catch(() => {
commit('SET_QUOTAL2', [])
resolve([]); resolve([]);
}) })
}) })

+ 147
- 44
src/utils/mixin.js View File

export default{
methods:{
reduceData(data){
let arr=data;
let year,code,quota1;
return arr.map(item=>{
if(item.quota1!=quota1&&(code==undefined||item.code==code)&&(item.year==year||year==undefined)){
quota1=item.quota1;
item.quota1Row=arr.filter(child=>{
return child.year==item.year&&child.code==item.code&&item.quota1==child.quota1
export let base = {
methods: {
reduceData(data) {
let arr = data;
let year, code, quota1;
return arr.map(item => {
if (item.quota1 != quota1 && (code == undefined || item.code == code) && (item.year == year || year == undefined)) {
quota1 = item.quota1;
item.quota1Row = arr.filter(child => {
return child.year == item.year && child.code == item.code && item.quota1 == child.quota1
}).length }).length
} }
if(item.code!=code&&(year==undefined||year==item.year)){
code=item.code;
item.codeRow=arr.filter(child=>{
return child.year==item.year&&child.code==item.code
if (item.code != code && (year == undefined || year == item.year)) {
code = item.code;
quota1 = ietm.quota1;
item.quota1Row = arr.filter(child => {
return child.year == item.year && child.code == item.code && item.quota1 == child.quota1
}).length
item.codeRow = arr.filter(child => {
return child.year == item.year && child.code == item.code
}).length
}
if (item.year != year) {
year = item.year;
code = item.code;
item.codeRow = arr.filter(child => {
return child.year == item.year && child.code == item.code
}).length
item.yearRow = arr.filter(child => {
return child.year == item.year
}).length;
}
return item;
})
},
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 2) {
if (row.yearRow) {
return {
rowspan: row.yearRow,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 1
}
}
}
if (columnIndex == 3 || columnIndex == 4) {
if (row.codeRow) {
return {
rowspan: row.codeRow,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 1
}
}
}
if (columnIndex == 5) {
if (row.quota1Row) {
return {
rowspan: row.quota1Row,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 1
}
}
}
}
},
}


export let assessing = {
methods: {
reduceData(data) {
let arr = data;
let quota1, quota2;
return arr.map(item => {
if (item.quota2 != quota2 && (quota1 == undefined || quota1 == item.quota1)) {
quota2 = item.quota2;
item.quota2Row = arr.filter(child => {
return child.quota1 == item.quota1 && child.quota2 == item.quota2
}).length }).length
} }
if(item.year!=year){
year=item.year;
item.yearRow=arr.filter(child=>{
return child.year==item.year

if (item.quota1 != quota1) {
quota1 = item.quota1;
quota2 = item.quota2;
item.quota2Row = arr.filter(child => {
return child.quota1 == item.quota1 && child.quota2 == item.quota2
}).length
item.quota1Row = arr.filter(child => {
return child.quota1 == item.quota1
}).length; }).length;
} }
return item; return item;
}) })
}, },
arraySpanMethod({row,column,rowIndex,columnIndex}){
if(columnIndex==2){
if(row.yearRow){
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 1) {
if (row.quota1Row) {
return { return {
rowspan:row.yearRow,
colspan:1
rowspan: row.quota1Row,
colspan: 1
} }
}else{
return{
rowspan:0,
colspan:1
} else {
return {
rowspan: 0,
colspan: 1
} }
} }
} }
if(columnIndex==3||columnIndex==4){
if(row.codeRow){
if (columnIndex == 2) {
if (row.quota2Row) {
return { return {
rowspan:row.codeRow,
colspan:1
rowspan: row.quota2Row,
colspan: 1
} }
}else{
return{
rowspan:0,
colspan:1
} else {
return {
rowspan: 0,
colspan: 1
} }
} }
} }
if(columnIndex==5){
if(row.quota1Row){
}
},
}

export let quota = {
methods: {
reduceData(data) {
let arr = data;
let quota;
return arr.map(item => {
if (item.quota != quota) {
quota = item.quota;
item.quotaRow = arr.filter(child => {
return child.quota == item.quota
}).length
}

return item;
})
},
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 1) {
if (row.quotaRow) {
return { return {
rowspan:row.quota1Row,
colspan:1
rowspan: row.quotaRow,
colspan: 1
} }
}else{
return{
rowspan:0,
colspan:1
} else {
return {
rowspan: 0,
colspan: 1
} }
} }
} }
} }
}, },
}
}


+ 100
- 29
src/views/assessingTarget/basicTarget.vue View File

<div class="basic-target ele-body"> <div class="basic-target ele-body">
<el-card shadow="never"> <el-card shadow="never">
<tab /> <tab />
<search :type="1" @search:task="getDataList($event)"/>
<search :type="1" @search:task="updateParams($event)" />
<el-table <el-table
:data="dataList" :data="dataList"
border border
highlight-current-row highlight-current-row
:height="tableHeight" :height="tableHeight"
v-loading="loading" v-loading="loading"
:span-method="arraySpanMethod"
> >
<el-table-column type="index" label="序号" align="center"> <el-table-column type="index" label="序号" align="center">
</el-table-column> </el-table-column>
align="center" align="center"
prop="points" prop="points"
></el-table-column> ></el-table-column>
<el-table-column
label="预计扣分"
min-width="60"
align="center"
>
<template slot-scope="{row,$index}">
<div @dblclick="showText($index,true)" style="height:100%">
<el-input v-model="row.expectedPoints" v-if="row.focus" @blur="showText($index,false);updatePoints(row)"></el-input>
<span v-else>{{row.expectedPoints}}</span>
<el-table-column label="预计扣分" min-width="60" align="center">
<template slot-scope="{ row, $index }">
<div @dblclick="showText($index, true)" style="height: 100%">
<el-input
v-model="row.expectedPoints"
v-if="row.focus"
@blur="
showText($index, false);
updatePoints(row);
"
></el-input>
<span v-else>{{ row.expectedPoints }}</span>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
label="牵头部门" label="牵头部门"
min-width="80"
min-width="150"
align="center" align="center"
prop="leaderDept" prop="leaderDept"
></el-table-column>
>
<template slot-scope="{ row, $index }">
<div
@dblclick="showDep($index, true)"
style="height: 45px;width:100%"
>
<treeselect
@blur="
showSelect($index, false);
updateDep(row);
"
v-if="row.selectFocus"
v-model="row.leaderDept"
:options="department"
placeholder="请选择牵头部门"
:defaultExpandLevel="2"
:normalizer="
(d) => {
return {
id: d.name,
label: d.name,
children:
d.children && d.children.length > 0
? d.children
: undefined,
};
}
"
/>
<span v-else>{{ row.leaderDept }}</span>
</div>
</template>
</el-table-column>
<el-table-column <el-table-column
label="责任领导" label="责任领导"
min-width="80" min-width="80"
import search from "./search"; import search from "./search";
import taskTable from "./taskTable"; import taskTable from "./taskTable";
import api from "@/api/assessingTarget/basicTarget"; import api from "@/api/assessingTarget/basicTarget";
import { assessing } from "@/utils/mixin";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from "@riophae/vue-treeselect"; // 下拉树
import { mapGetters } from "vuex";
export default { export default {
components: { components: {
tab, tab,
search, search,
taskTable, taskTable,
Treeselect,
}, },
mixins: [assessing],
data() { data() {
return { return {
dataList: [], dataList: [],
loading: false, loading: false,
count: 0, count: 0,
tableHeight:document.documentElement.clientHeight - 470,
tableHeight: document.documentElement.clientHeight - 470,
page: { page: {
page: 1, page: 1,
limit: Math.floor( limit: Math.floor(
(document.documentElement.clientHeight - 470 - 45) / 45 (document.documentElement.clientHeight - 470 - 45) / 45
), ),
}, },
searchParams: {
quota1: "",
quota2: "",
},
}; };
}, },
created() { created() {
this.getDataList(); this.getDataList();
}, },
computed: {
...mapGetters(["department"]),
},
methods: { methods: {
updatePoints(row){
api.updatePoints({basicTaskId:row.id,expectedPoints:row.expectedPoints}).then(res=>{
this.$message({type:"success",message:"修改成功"});
}).catch(()=>{
this.$message.error("修改失败");
this.getDataList();
})
updateParams(data) {
this.searchParams = data;
this.resetCurrentPage();
this.getDataList();
},
resetCurrentPage() {
let page = this.page;
page.page = 1;
this.page = page;
},
updatePoints(row) {
api
.updatePoints({
basicTaskId: row.id,
expectedPoints: row.expectedPoints,
})
.then((res) => {
this.$message({ type: "success", message: "修改成功" });
})
.catch(() => {
this.$message.error("修改失败");
this.getDataList();
});
},
showText(index, bool) {
console.log(index);
let data = this.dataList;
data[index].focus = bool;
this.dataList = data;
}, },
showText(index,bool){
console.log(index)
let data=this.dataList;
data[index].focus=bool;
this.dataList=data;
showDep(index, bool) {
let data = this.dataList;
data[index].selectFocus = bool;
this.dataList = data;
}, },
getDataList(params) {
getDataList() {
this.loading = true; this.loading = true;
api api
.getList(params ? Object.assign(this.page, params) : this.page)
.getList(Object.assign({}, this.searchParams, this.page))
.then((res) => { .then((res) => {
this.loading = false; this.loading = false;
let data = res.data.data.records; let data = res.data.data.records;
data = data.map((item) => { data = data.map((item) => {
item.year = item.year + ""; item.year = item.year + "";
item.focus=false;
item.focus = false;
item.selectFocus = false;
return item; return item;
}); });
this.dataList = data;
this.dataList = this.reduceData(data);
this.count = res.data.data.total; this.count = res.data.data.total;
}) })
.catch(() => { .catch(() => {

+ 21
- 4
src/views/assessingTarget/constraint.vue View File

<div class="reward ele-body"> <div class="reward ele-body">
<el-card shadow="never"> <el-card shadow="never">
<tab /> <tab />
<search :type="3" @search:task="getDataList($event)" />
<search :type="3" @search:task="updateParams($event)" />
<el-table <el-table
:data="dataList" :data="dataList"
border border
highlight-current-row highlight-current-row
:height="tableHeight" :height="tableHeight"
v-loading="loading" v-loading="loading"
:span-method="arraySpanMethod"
> >
<el-table-column type="index" label="序号" align="center"> <el-table-column type="index" label="序号" align="center">
</el-table-column> </el-table-column>
import tab from "./tab"; import tab from "./tab";
import search from "./search"; import search from "./search";
import api from "@/api/assessingTarget/constraint"; import api from "@/api/assessingTarget/constraint";
import { quota } from "@/utils/mixin";
export default { export default {
components: { components: {
tab, tab,
search, search,
}, },
mixins: [quota],
data() { data() {
return { return {
dataList: [], dataList: [],
(document.documentElement.clientHeight - 470 - 45) / 45 (document.documentElement.clientHeight - 470 - 45) / 45
), ),
}, },
searchParams: {
quota1: "",
quota2: "",
},
}; };
}, },
created() { created() {
this.getDataList(); this.getDataList();
}, },
methods: { methods: {
updateParams(data) {
this.searchParams = data;
this.resetCurrentPage();
this.getDataList();
},
resetCurrentPage() {
let page = this.page;
page.page = 1;
this.page = page;
},
updatePoints(row) { updatePoints(row) {
api api
.updatePoints({ .updatePoints({
data[index].focus = bool; data[index].focus = bool;
this.dataList = data; this.dataList = data;
}, },
getDataList(params) {
getDataList() {
this.loading = true; this.loading = true;
api api
.getList(params ? Object.assign(this.page, params) : this.page)
.getList(Object.assign({}, this.searchParams, this.page))
.then((res) => { .then((res) => {
this.loading = false; this.loading = false;
let data = res.data.data.records; let data = res.data.data.records;
item.focus = false; item.focus = false;
return item; return item;
}); });
this.dataList = data;
this.dataList = this.reduceData(data);
this.count = res.data.data.total; this.count = res.data.data.total;
}) })
.catch(() => { .catch(() => {

+ 27
- 4
src/views/assessingTarget/reward.vue View File

<div class="reward ele-body"> <div class="reward ele-body">
<el-card shadow="never"> <el-card shadow="never">
<tab /> <tab />
<search :type="2" @search:task="getDataList($event)" />
<search :type="2" @search:task="updateParams($event)" />
<el-table <el-table
:data="dataList" :data="dataList"
border border
highlight-current-row highlight-current-row
:height="tableHeight" :height="tableHeight"
v-loading="loading" v-loading="loading"
:span-method="arraySpanMethod"
> >
<el-table-column type="index" label="序号" align="center"> <el-table-column type="index" label="序号" align="center">
</el-table-column> </el-table-column>
prop="quota2" prop="quota2"
></el-table-column> ></el-table-column>
</template> </template>
<el-table-column
label="考核指标"
min-width="150"
align="center"
prop=""
></el-table-column>
<el-table-column <el-table-column
label="封顶分值" label="封顶分值"
min-width="60" min-width="60"
class="ele-pagination-circle" class="ele-pagination-circle"
@current-change="getDataList()" @current-change="getDataList()"
/> />
F
</el-card> </el-card>
</div> </div>
</template> </template>
import tab from "./tab"; import tab from "./tab";
import search from "./search"; import search from "./search";
import api from "@/api/assessingTarget/reward"; import api from "@/api/assessingTarget/reward";
import {assessing} from "@/utils/mixin"
export default { export default {
components: { components: {
tab, tab,
search, search,
}, },
mixins:[assessing],
data() { data() {
return { return {
dataList: [], dataList: [],
(document.documentElement.clientHeight - 470 - 45) / 45 (document.documentElement.clientHeight - 470 - 45) / 45
), ),
}, },
searchParams: {
quota1: "",
quota2: "",
},
}; };
}, },
created() { created() {
this.getDataList(); this.getDataList();
}, },
methods: { methods: {
updateParams(data) {
this.searchParams = data;
this.resetCurrentPage();
this.getDataList();
},
resetCurrentPage() {
let page = this.page;
page.page = 1;
this.page = page;
},
updatePoints(row) { updatePoints(row) {
api api
.updatePoints({ .updatePoints({
getDataList(params) { getDataList(params) {
this.loading = true; this.loading = true;
api api
.getList(params ? Object.assign(this.page, params) : this.page)
.getList(Object.assign({}, this.searchParams, this.page))
.then((res) => { .then((res) => {
this.loading = false; this.loading = false;
let data = res.data.data.records; let data = res.data.data.records;
item.focus = false; item.focus = false;
return item; return item;
}); });
this.dataList = data;
this.dataList = this.reduceData(data);
// this.dataList = data;
this.count = res.data.data.total; this.count = res.data.data.total;
}) })
.catch(() => { .catch(() => {

+ 58
- 19
src/views/assessingTarget/search.vue View File

></el-input> ></el-input>
</el-form-item> </el-form-item>
</template> </template>
<!-- <el-form-item label="牵头部门:">
<el-select filterabel clearable v-model="searchParams.leaderDept">
<el-option></el-option>
</el-select>
<el-form-item label="牵头部门:">
<treeselect
v-model="searchParams.leaderDept"
:options="department"
placeholder="请选择牵头部门"
:defaultExpandLevel="2"
:normalizer="
(d) => {
return {
id: d.name,
label: d.name,
children: (d.children&&d.children.length>0)?d.children:undefined,
};
}
"
/>
</el-form-item> </el-form-item>
<el-form-item label="配合部门:"> <el-form-item label="配合部门:">
<el-select filterable clearable>
<el-option></el-option>
</el-select>
</el-form-item> -->
<treeselect
v-model="searchParams.cooperateDept"
:options="department"
placeholder="请选择配合部门"
:defaultExpandLevel="2"
:normalizer="
(d) => {
return {
id: d.name,
label: d.name,
children: (d.children&&d.children.length>0)?d.children:undefined,
};
}
"
/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="search">查询</el-button> <el-button type="primary" size="small" @click="search">查询</el-button>
<el-button type="default" size="small" @click="clear();search()">清空</el-button>
<el-button
type="default"
size="small"
@click="
clear();
search();
"
>清空</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>


<script> <script>
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from "@riophae/vue-treeselect"; // 下拉树
import { mapGetters, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
export default { export default {
props: { props: {
}, },
}, },
}, },
components: {
Treeselect,
},
data() { data() {
return { return {
searchParams: { searchParams: {
quota1: "", quota1: "",
quota2: "", quota2: "",
leaderDept: undefined,
cooperateDept: undefined,
}, },
}; };
}, },
created() { created() {
this.getQuota1List(this.type); this.getQuota1List(this.type);
this.getDepartment();
this.getDepartment(1);
}, },
methods: { methods: {
...mapActions({ ...mapActions({
getQuota2List: "base/getQuota2List", getQuota2List: "base/getQuota2List",
getDepartment: "base/getDepartment", getDepartment: "base/getDepartment",
}), }),
clear(){
this.searchParams={
quota1:'',
quota2:""
}
clear() {
this.searchParams = {
quota1: "",
quota2: "",
};
},
search() {
this.$emit("search:task", this.searchParams);
}, },
search(){
this.$emit("search:task",this.searchParams);
}
}, },
computed: { computed: {
...mapGetters(["quota1", "quota2"]),
...mapGetters(["quota1", "quota2", "department"]),
}, },
watch: { watch: {
"searchParams.quota1"(val) { "searchParams.quota1"(val) {

+ 33
- 17
src/views/basicTable/category.vue View File

<template> <template>
<div class="category ele-body"> <div class="category ele-body">
<el-card shadow="never"> <el-card shadow="never">
<search @search="getDataList($event)"/>
<search @search="updateParams($event)" />
<div class="operating"> <div class="operating">
<el-button size="small" type="warning" @click="add">新增</el-button> <el-button size="small" type="warning" @click="add">新增</el-button>
<el-button size="small" type="default" @click="remove()" <el-button size="small" type="default" @click="remove()"
data() { data() {
return { return {
// searchParams: {}, // searchParams: {},
loading:false,
loading: false,
dataList: [], dataList: [],
count: 0, count: 0,
page: { page: {
name: [{ required: true, message: "请输入表格名称", trigger: "blur" }], name: [{ required: true, message: "请输入表格名称", trigger: "blur" }],
year: [{ required: true, message: "请输入考核年度", trigger: "blur" }], year: [{ required: true, message: "请输入考核年度", trigger: "blur" }],
}, },
searchParams: {
year: "",
code: "",
name: "",
},
}; };
}, },
created() { created() {
this.getDataList(); this.getDataList();
this.$store.dispatch('base/getQuota1List',1)
this.$store.dispatch("base/getQuota1List", 1);
}, },
methods: { methods: {
updateParams(data){
this.searchParams=data;
this.resetCurrentPage();
this.getDataList();
},
resetCurrentPage() {
let page = this.page;
page.page = 1;
this.page = page;
},
selectionChange(rows) { selectionChange(rows) {
this.multipleSelection = rows; this.multipleSelection = rows;
}, },
getDataList(params) {
this.loading=true
getDataList() {
this.loading = true;
api api
.getList(params ? Object.assign(this.page, params) : this.page)
.getList(Object.assign({},this.searchParams,this.page))
.then((res) => { .then((res) => {
this.loading=false
this.loading = false;
let data = res.data.data.records; let data = res.data.data.records;
data = data.map((item) => { data = data.map((item) => {
item.year = item.year + ""; item.year = item.year + "";
this.count = res.data.data.total; this.count = res.data.data.total;
}) })
.catch(() => { .catch(() => {
this.loading=false
this.loading = false;
this.dataList = []; this.dataList = [];
this.count = 0; this.count = 0;
}); });
ids.join(","); ids.join(",");
this.$confirm("确定要删除选中表格?", "提示", { type: "warning" }) this.$confirm("确定要删除选中表格?", "提示", { type: "warning" })
.then(() => { .then(() => {
this.loading=true
this.loading = true;
api api
.delete(ids) .delete(ids)
.then(() => { .then(() => {
this.loading=false
this.loading = false;
this.$message({ type: "success", message: "删除成功" }); this.$message({ type: "success", message: "删除成功" });
}) })
.catch(() => { .catch(() => {
this.loading=fa;se
this.loading = fa;
se;
this.$message.error("删失败"); this.$message.error("删失败");
}); });
}) })
.catch(() => 0); .catch(() => 0);
} else { } else {
// 单个删除 // 单个删除
this.loading=true;
this.loading = true;
api api
.delete(row.id) .delete(row.id)
.then(() => { .then(() => {
this.loading=false
this.loading = false;
this.$message({ type: "success", message: "删除成功" }); this.$message({ type: "success", message: "删除成功" });
}) })
.catch(() => { .catch(() => {
this.loading=false
this.loading = false;
this.$message.error("删除失败"); this.$message.error("删除失败");
}); });
} }
save() { save() {
this.$refs["editForm"].validate((valid) => { this.$refs["editForm"].validate((valid) => {
if (valid) { if (valid) {
this.loading=true;
this.loading = true;
let action = this.form.id ? "edit" : "add"; let action = this.form.id ? "edit" : "add";
api[action](this.form) api[action](this.form)
.then(() => { .then(() => {
this.loading=false
this.loading = false;
this.$message({ this.$message({
type: "success", type: "success",
message: this.form.id ? "修改成功" : "添加成功", message: this.form.id ? "修改成功" : "添加成功",
this.getDataList(this.page); this.getDataList(this.page);
}) })
.catch(() => { .catch(() => {
this.loading=false
this.loading = false;
this.$message.error(this.form.id ? "修改失败" : "添加失败"); this.$message.error(this.form.id ? "修改失败" : "添加失败");
}) })
.finally(() => { .finally(() => {

+ 24
- 9
src/views/basicTable/conventional.vue View File

<template> <template>
<div class="conventional ele-body"> <div class="conventional ele-body">
<el-card shadow="never"> <el-card shadow="never">
<search @search="getDataList($event)"/>
<search @search="updateParams($event)" />
<!-- <div class="operating"> <!-- <div class="operating">
<el-button size="small" type="warning" @click="add">新增</el-button> <el-button size="small" type="warning" @click="add">新增</el-button>
<el-button size="small" type="default">批量删除</el-button> <el-button size="small" type="default">批量删除</el-button>
border border
:data="dataList" :data="dataList"
:height="tableHeight" :height="tableHeight"
:sort-by="['year','code','quota1']"
:sort-by="['year', 'code', 'quota1']"
:span-method="arraySpanMethod" :span-method="arraySpanMethod"
v-loading="loading" v-loading="loading"
> >
<script> <script>
import search from "./search"; import search from "./search";
import api from "@/api/basicTable/conventionl.js"; import api from "@/api/basicTable/conventionl.js";
import mixin from "@/utils/mixin";
import {base} from "@/utils/mixin";
export default { export default {
components: { components: {
search, search,
}, },
mixins: [mixin],
mixins: [base],
data() { data() {
return { return {
dataList: [], dataList: [],
name: [{ required: true, message: "请输入表格名称", trigger: "blur" }], name: [{ required: true, message: "请输入表格名称", trigger: "blur" }],
year: [{ required: true, message: "请输入考核年度" }], year: [{ required: true, message: "请输入考核年度" }],
}, },
searchParams: {
year: "",
code: "",
name: "",
},
}; };
}, },
created() { created() {
this.getDataList(); this.getDataList();
}, },
methods: { methods: {
getDataList(params) {
this.loading=true;
updateParams(data){
this.searchParams=data;
this.resetCurrentPage();
this.getDataList();
},
resetCurrentPage() {
let page = this.page;
page.page = 1;
this.page = page;
},
getDataList() {
this.loading = true;
api api
.getList(params ? Object.assign(this.page, params) : this.page)
.getList(Object.assign({},this.searchParams,this.page))
.then((res) => { .then((res) => {
this.loading=false;
this.loading = false;
let data = res.data.data.records; let data = res.data.data.records;
data = data.map((item) => { data = data.map((item) => {
item.year = item.year + ""; item.year = item.year + "";
this.count = res.data.data.total; this.count = res.data.data.total;
}) })
.catch(() => { .catch(() => {
this.loading=false
this.loading = false;
this.dataList = []; this.dataList = [];
this.count = 0; this.count = 0;
}); });

Loading…
Cancel
Save