<template>
|
<div class="dispatch">
|
<avue-tabs :option="optionTABS" @change="handleChangeTABS"></avue-tabs>
|
<span v-if="typeTABS.prop === 'tab1'">
|
<!-- <avue-crud
|
:option="option"
|
:data="data"
|
:page.sync="page"
|
ref="crudrec"
|
@on-load="onLoad"
|
:table-loading="loading"
|
@row-save="rowSave"
|
@search-change="searchChange"
|
@search-reset="searchReset"
|
@row-update="rowUpdate"
|
@row-del="rowDel"
|
@selection-change="selectionChange"
|
@refresh-change="refreshChange"
|
>
|
<template slot="menuLeft">
|
<el-button
|
type="danger"
|
size="small"
|
plain
|
icon="el-icon-delete"
|
@click="handleDelete"
|
>删 除
|
</el-button>
|
</template>
|
</avue-crud> -->
|
<avue-form ref="form" v-model="obj0" :option="option0">
|
<!-- <template slot-scope="scope" slot="menuForm">
|
<el-button @click="tip">自定义按钮</el-button>
|
</template> -->
|
</avue-form>
|
</span>
|
<span v-else-if="typeTABS.prop === 'tab2'">
|
<avue-crud
|
:option="option1"
|
:data="data1"
|
:page.sync="page1"
|
ref="crudrec1"
|
:table-loading="loading1"
|
@row-save="rowSave1"
|
@search-change="searchChange1"
|
@search-reset="searchReset1"
|
@row-update="rowUpdate1"
|
@row-del="rowDel1"
|
@selection-change="selectionChange1"
|
@refresh-change="refreshChange1"
|
>
|
<!-- <template slot="menuLeft">
|
<el-button
|
type="danger"
|
size="small"
|
plain
|
icon="el-icon-delete"
|
@click="handleDelete1"
|
>删 除
|
</el-button>
|
</template> -->
|
</avue-crud>
|
</span>
|
<!-- <span v-else-if="typeTABS.prop === 'tab3'">选项卡内容3</span> -->
|
</div>
|
</template>
|
|
<script>
|
import { column, column1 } from "./data";
|
import {
|
// getdata,
|
// adddata,
|
// update,
|
// remove,
|
getdata1,
|
adddata1,
|
update1,
|
remove1,
|
} from "@/api/dispatch/dispatch";
|
|
export default {
|
data() {
|
return {
|
typeTABS: {}, //标签页
|
optionTABS: {
|
column: [
|
{
|
// icon: "el-icon-info",
|
label: "派遣服务公司详情",
|
prop: "tab1",
|
},
|
{
|
// icon: "el-icon-info",
|
label: "派遣记录",
|
prop: "tab2",
|
},
|
// {
|
// icon: "el-icon-info",
|
// label: "选项卡3",
|
// prop: "tab3",
|
// },
|
],
|
},
|
|
id: "", //记录归属id
|
//基本信息
|
//保安单位信息表单
|
obj0: {
|
// title: "我是头部标题",
|
},
|
option0: {
|
emptyBtn: false,
|
submitBtn: false,
|
gutter: 30,
|
column: column,
|
},
|
loading1: true, //派遣记录
|
selectionList1: [],
|
page1: {
|
pageSize: 10,
|
currentPage: 1,
|
total: 0,
|
...this.$store.state.control.changePageSize,
|
},
|
query1: {},
|
data1: [],
|
option1: {
|
// card: true,
|
tip: false,
|
index: true,
|
menu: false,
|
searchSize: "mini",
|
searchMenuSpan: 8,
|
height: 563,
|
// menuWidth: 160,
|
align: "center",
|
selection: true,
|
column: column1,
|
cellBtn: false,
|
addBtn: false,
|
},
|
};
|
},
|
computed: {
|
// ids() {
|
// let ids = [];
|
// this.selectionList.forEach((ele) => {
|
// ids.push(ele.id);
|
// });
|
// return ids.join(",");
|
// },
|
ids1() {
|
let ids1 = [];
|
this.selectionList1.forEach((ele) => {
|
ids1.push(ele.id);
|
});
|
return ids1.join(",");
|
},
|
},
|
methods: {
|
handleChangeTABS(column) {
|
this.typeTABS = column;
|
if (column.prop == "tab1") {
|
this.loading1 = false;
|
// this.onLoad(this.page);
|
} else if (column.prop == "tab2") {
|
// this.loading = false;
|
this.onLoad1(this.page1); //第二个表格不会自动执行
|
}
|
// this.$message.success(JSON.stringify(column));
|
},
|
|
//派遣记录
|
sizeChange1(val) {
|
this.page1.currentPage = 1;
|
this.page1.pageSize = val;
|
// this.getData();
|
this.onLoad1(this.page1, this.query1);
|
// this.$message.success("行数" + val);
|
},
|
currentChange1(val) {
|
this.page1.currentPage = val;
|
// this.getData();
|
this.onLoad1(this.page1, this.query1);
|
// this.$message.success("页码" + val);
|
},
|
rowSave1(form, done, loading) {
|
// var that = this;
|
// var form = this.data1[0];
|
// delete form.id;
|
// for (var k = 0; k < 13; k++) {
|
// form["deptId"] = form.tenantName;
|
// form["tenantName"] = form.$tenantName;
|
form["dispatcherUnitId"] = this.id;
|
console.log(form);
|
|
adddata1(form).then(
|
(res) => {
|
this.onLoad1(this.page1);
|
this.$message({
|
type: "success",
|
message: "操作成功!",
|
});
|
done();
|
},
|
(error) => {
|
window.console.log(error);
|
loading();
|
}
|
);
|
// }
|
},
|
searchChange1(params, done) {
|
this.query1 = params;
|
this.page1.currentPage = 1;
|
this.onLoad1(this.page1, params);
|
done();
|
},
|
searchReset1() {
|
this.query = {};
|
this.onLoad1(this.page1);
|
},
|
rowUpdate1(row, index, done, loading) {
|
// row["deptId"] = row.tenantName;
|
// row["tenantName"] = row.$tenantName;
|
row["dispatcherUnitId"] = this.id;
|
console.log(row, "row");
|
update1(row).then(
|
() => {
|
this.onLoad1(this.page1);
|
this.$message({
|
type: "success",
|
message: "操作成功!",
|
});
|
done();
|
},
|
(error) => {
|
window.console.log(error);
|
loading();
|
}
|
);
|
},
|
rowDel1(row) {
|
this.$confirm("确定将选择数据删除?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
return remove1(row.id);
|
})
|
.then(() => {
|
this.onLoad1(this.page1);
|
this.$message({
|
type: "success",
|
message: "操作成功!",
|
});
|
});
|
},
|
selectionChange1(list) {
|
this.selectionList1 = list;
|
console.log(this.selectionList1.length);
|
},
|
handleDelete1() {
|
console.log(this.selectionList1);
|
if (this.selectionList1.length === 0) {
|
this.$message.warning("请选择至少一条数据");
|
return;
|
}
|
this.$confirm("确定将选择数据删除?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
return remove1(this.ids1);
|
})
|
.then(() => {
|
this.onLoad1(this.page1);
|
this.$message({
|
type: "success",
|
message: "操作成功!",
|
});
|
this.$refs.crudrec1.toggleSelection();
|
});
|
},
|
refreshChange1() {
|
this.onLoad1(this.page1, this.query1);
|
},
|
|
//
|
onLoad1(page, params = {}) {
|
this.loading1 = true;
|
// params["cardid"] = this.cardid;
|
// params["name"] = this.name;
|
// params["dispatcherCompany"] = this.dispatcherCompany;
|
params["dispatcherUnitId"] = this.id;
|
getdata1(
|
page.currentPage,
|
page.pageSize,
|
Object.assign(params, this.query)
|
).then((res) => {
|
const data = res.data.data;
|
this.page1.total = data.total;
|
this.data1 = data.records;
|
// for (var k in this.data1) {
|
// this.data1[k].securityName = this.data1[k].securityName.split(",");
|
// this.data1[k].securityName = this.data1[k].securityName.join(" | ");
|
// }
|
this.loading1 = false;
|
});
|
},
|
//派遣记录
|
saveLock(name, val) {
|
localStorage.setItem(name, val);
|
},
|
readLock(name) {
|
return localStorage.getItem(name);
|
},
|
},
|
mounted() {
|
this.typeTABS = this.optionTABS.column[0];
|
var row = {};
|
if (this.readLock("paqiandata") != null) {
|
row = JSON.parse(this.readLock("paqiandata"));
|
this.obj0.name = row.name;
|
for (var k in row) {
|
this.obj0[k] = row[k];
|
}
|
console.log(this.obj0, 11111111);
|
this.id = row.id;
|
if (this.readLock("paqiandataS") != null) {
|
var b = JSON.parse(this.readLock("paqiandataS"));
|
var i = 0;
|
for (var k in b) {
|
if (b[k].name == row.name) {
|
i = 1;
|
}
|
}
|
if (i == 1) {
|
// console.log("存在");
|
} else {
|
this.obj0 = {};
|
this.obj0.name = row.name + " 该派遣单位已删除";
|
window.localStorage.removeItem("paqiandata");
|
this.id = 1244241;
|
}
|
}
|
} else {
|
this.obj0.name = " 未选择派遣单位";
|
}
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.dispatch {
|
width: 100%;
|
height: 100%;
|
// border: 1px solid #000;
|
box-sizing: border-box;
|
}
|
.el-collapse-item {
|
padding-top: 15px !important;
|
}
|
</style>
|