Commit 9c532ada authored by renjintao's avatar renjintao

resourceMangement/productionResources

parent 7176f54e
<template> <template>
<div class="resources-p h100"> <div class="resources-p h100">
<DataGrid <DataGrid :columns="columns" ref="grid" :action="action" :high="false" @on-selection-change="onSelect">
:columns="columns" <template slot="easySearch">
ref="grid" <Form ref="formInline" :model="easySearch" inline>
:action="action" <FormItem prop="keys">
:high="false" <Input placeholder="请输入资源名称/编号/类型/部门" v-model="easySearch.keys.value" />
@on-selection-change="onSelect" </FormItem>
> <FormItem>
<template slot="easySearch"> <Button type="primary" @click="search">查询</Button>
<Form ref="formInline" :model="easySearch" inline> </FormItem>
<FormItem prop="keys"> </Form>
<Input placeholder="请输入资源名称/编号/类型/部门" v-model="easySearch.keys.value" /> </template>
</FormItem> <template slot="batch">
<FormItem> <Form ref="form" :model="entity" :rules="rules" :label-width="90" class="form-row">
<Button type="primary" @click="search">查询</Button> <Row>
</FormItem> <Col span="8">
</Form> <FormItem :label="l('isimportant')" prop="isimportant">
</template> <RadioGroup v-model="entity.isimportant">
<template slot="batch"> <Radio label="1"></Radio>
<Form ref="form" :model="entity" :rules="rules" :label-width="90" class="form-row"> <Radio label="2"></Radio>
<Row> </RadioGroup>
<Col span="8"> </FormItem>
<FormItem :label="l('isimportant')" prop="isimportant"> </Col>
<RadioGroup v-model="entity.isimportant"> <Col span="8">
<Radio label="1"></Radio> <FormItem :label="l('capabilityValue')">
<Radio label="2"></Radio> <InputNumber v-model="entity.capabilityValue"></InputNumber>
</RadioGroup> </FormItem>
</FormItem> </Col>
</Col> <Col span="8">
<Col span="8"> <FormItem>
<FormItem :label="l('capabilityValue')"> <Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<InputNumber v-model="entity.capabilityValue"></InputNumber> </FormItem>
</FormItem> </Col>
</Col> </Row>
<Col span="8"> </Form>
<FormItem> </template>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
</FormItem>
</Col>
</Row>
</Form>
</template>
</DataGrid> </DataGrid>
<Modal v-model="editModal" title="设置日历" footer-hide> <Modal v-model="editModal" title="设置日历" footer-hide width="1000">
<Set :eid="curId" @on-close="cancel" @on-ok="addOk" /> <Set :eid="curId" @on-close="cancel" @on-ok="addOk" />
</Modal> </Modal>
<Modal v-model="deletelModal" title="删除" @on-ok="removeOk" @on-cancel="cancel"> <Modal v-model="deletelModal" title="删除" @on-ok="removeOk" @on-cancel="cancel">
<p>确定删除?</p> <p>确定删除?</p>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
import Set from "./set"; import Set from "./set";
export default { export default {
name: "list", name: "list",
components: { components: {
Set, Set,
}, },
data() { data() {
return { return {
action: Api.index, action: Api.index,
easySearch: { easySearch: {
keys: { op: "title,code,type,departTitle", value: null }, keys: {
}, op: "title,code,type,departTitle",
entity: { value: null
isimportant: "1", },
}, },
disabled: false, entity: {
ids: [], isimportant: "1",
editModal: false, },
deletelModal: false, disabled: false,
curId: 0, ids: [],
rules: { editModal: false,
isimportant: [{ required: true, message: "必填", trigger: "blur" }], deletelModal: false,
capabilityValue: [{ required: true, message: "必填", trigger: "blur" }], curId: 0,
}, rules: {
columns: [ isimportant: [{
{ key: "id", title: this.l("id"), hide: true, align: "left" }, required: true,
{ message: "必填",
type: "selection", trigger: "blur"
width: 70, }],
align: "center", capabilityValue: [{
}, required: true,
// { message: "必填",
// key: "deleterUserId", trigger: "blur"
// title: this.l("deleterUserId"), }],
// hide: true, },
// align: "left" columns: [{
// }, key: "id",
{ title: this.l("id"),
key: "title", hide: true,
title: this.l("title"), align: "left"
align: "left", },
easy: true, {
high: true, type: "selection",
width: 70,
align: "center",
},
// {
// key: "deleterUserId",
// title: this.l("deleterUserId"),
// hide: true,
// align: "left"
// },
{
key: "title",
title: this.l("title"),
align: "left",
easy: true,
high: true,
},
{
key: "code",
title: this.l("code"),
align: "left",
easy: true,
high: true,
},
{
key: "type",
title: this.l("type"),
align: "center",
code: "aps.resource.type",
easy: true,
high: true,
},
// {
// key: "property",
// title: this.l("property"),
// align: "left",
// high: true
// },
// {
// key: "departId",
// title: this.l("departId"),
// align: "left",
// high: true
// },
{
key: "departTitle",
title: this.l("departTitle"),
align: "left",
easy: true,
high: true,
},
{
key: "isimportant",
title: this.l("isimportant"),
align: "left",
render: (h, params) => {
let statuse = params.row.isimportant;
let text = statuse == 1 ? "是" : statuse == 2 ? "否" : "";
return h("span", {}, text);
},
},
{
key: "capabilityValue",
title: this.l("capabilityValue"),
align: "left",
easy: true,
high: true,
},
{
key: "calId",
title: this.l("calId"),
align: "center",
easy: true,
high: true,
},
{
key: "holidayCalId",
title: this.l("holidayCalId"),
align: "center",
easy: true,
high: true,
},
{
key: "calName",
title: this.l("calName"),
align: "left",
easy: true,
high: true,
},
{
key: "holidayCalName",
title: this.l("holidayCalName"),
align: "left",
easy: true,
high: true,
},
{
title: "操作",
key: "id",
width: 140,
align: "center",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.edit(params.row.id)
},
},
"设置"
),
h(
"op", {
attrs: {
oprate: "remove",
title: "删除"
},
on: {
click: () => this.remove(params.row.id)
},
},
"删除"
),
]);
},
},
],
};
},
mounted() {
console.log(this);
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
addOk() {
this.$refs.grid.load();
this.editModal = false;
this.curId = 0;
}, },
{ search() {
key: "code", this.$refs.grid.reload(this.easySearch);
title: this.l("code"),
align: "left",
easy: true,
high: true,
}, },
{
key: "type", edit(id) {
title: this.l("type"), this.editModal = true;
align: "center", this.curId = id;
code: "aps.resource.type",
easy: true,
high: true,
}, },
// {
// key: "property", remove(id) {
// title: this.l("property"), this.deletelModal = true;
// align: "left", this.curId = id;
// high: true
// },
// {
// key: "departId",
// title: this.l("departId"),
// align: "left",
// high: true
// },
{
key: "departTitle",
title: this.l("departTitle"),
align: "left",
easy: true,
high: true,
}, },
{ removeOk() {
key: "isimportant", Api.delete({
title: this.l("isimportant"), id: this.curId
align: "left", }).then((r) => {
render: (h, params) => { if (r.success) {
let statuse = params.row.isimportant; this.$refs.grid.load();
let text = statuse == 1 ? "是" : statuse == 2 ? "否" : ""; this.deletelModal = false;
return h("span", {}, text); this.$Message.success("删除成功");
}, }
});
}, },
{ removeCancel() {
key: "capabilityValue", this.deletelModal = false;
title: this.l("capabilityValue"),
align: "left",
easy: true,
high: true,
}, },
{ cancel() {
key: "calId", this.curId = 0;
title: this.l("calId"), this.addModal = false;
align: "center", this.detailModal = false;
easy: true, this.editModal = false;
high: true, this.deletedlModal = false;
}, },
{ onSelect(a, b) {
key: "holidayCalId", console.log(a);
title: this.l("holidayCalId"), //批量选择
align: "center", let selectRows = a;
easy: true, this.ids = [];
high: true, selectRows.forEach((e) => {
this.ids.push(e.id);
});
}, },
{
key: "calName", handleSubmit() {
title: this.l("calName"), this.$refs.form.validate((v) => {
align: "left", if (v) {
easy: true, let data = {
high: true, ids: this.ids,
isimportant: this.entity.isimportant,
capabilityValue: this.entity.capabilityValue,
};
Api.set(data)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$refs.grid.load();
this.$refs.grid.footerToolbar = false;
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
} else {
this.$Message.error("请输入必填项");
}
});
}, },
{ handleClose() {
key: "holidayCalName", this.footer = false;
title: this.l("holidayCalName"), this.handleSelectAll(false);
align: "left",
easy: true,
high: true,
}, },
{ l(key) {
title: "操作", let vkey = "plan_resource" + "." + key;
key: "id", return this.$t(vkey) || key;
width: 140,
align: "center",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row.id) },
},
"设置"
),
h(
"op",
{
attrs: { oprate: "remove", title: "删除" },
on: { click: () => this.remove(params.row.id) },
},
"删除"
),
]);
},
}, },
],
};
},
mounted() {
console.log(this);
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
methods: {
addOk() {
this.$refs.grid.load();
this.editModal = false;
this.curId = 0;
},
search() {
this.$refs.grid.reload(this.easySearch);
},
edit(id) {
this.editModal = true;
this.curId = id;
},
remove(id) {
this.deletelModal = true;
this.curId = id;
},
removeOk() {
Api.delete({ id: this.curId }).then((r) => {
if (r.success) {
this.$refs.grid.load();
this.deletelModal = false;
this.$Message.success("删除成功");
}
});
},
removeCancel() {
this.deletelModal = false;
}, },
cancel() {
this.curId = 0;
this.addModal = false;
this.detailModal = false;
this.editModal = false;
this.deletedlModal = false;
},
onSelect(a, b) {
console.log(a);
//批量选择
let selectRows = a;
this.ids = [];
selectRows.forEach((e) => {
this.ids.push(e.id);
});
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
let data = {
ids: this.ids,
isimportant: this.entity.isimportant,
capabilityValue: this.entity.capabilityValue,
};
Api.set(data)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$refs.grid.load();
this.$refs.grid.footerToolbar = false;
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
} else {
this.$Message.error("请输入必填项");
}
});
},
handleClose() {
this.footer = false;
this.handleSelectAll(false);
},
l(key) {
let vkey = "plan_resource" + "." + key;
return this.$t(vkey) || key;
},
},
}; };
</script> </script>
<style lang="less"> <style lang="less">
@import "../../../assets/css/custom.less"; @import "../../../assets/css/custom.less";
.resources-p { .resources-p {
.form-row { .form-row {
width: 600px; width: 600px;
margin-left: 50px; margin-left: 50px;
.ivu-form-item-label {
color: @form-color; .ivu-form-item-label {
color: @form-color;
}
}
.ivu-footer-toolbar-right {
width: 1100px;
position: relative !important;
}
.btn {
position: absolute !important;
top: 12px !important;
right: 40px !important;
} }
}
.ivu-footer-toolbar-right {
width: 1100px;
position: relative !important;
}
.btn {
position: absolute !important;
top: 12px !important;
right: 40px !important;
}
} }
</style> </style>
\ No newline at end of file
<template> <template>
<Form ref="form" :model="formItem" :rules="rules" :label-width="90"> <Form ref="form" :model="formItem" :rules="rules" :label-width="110">
<Row> <Row>
<Col span="12"> <Col span="12">
<FormItem label="资源名称" prop="equip_name"> <FormItem label="资源名称" prop="equip_name">
<Input v-model="formItem.equip_name" placeholder="请输入设备名称" readonly></Input> <Input v-model="formItem.equip_name" placeholder="请输入设备名称" readonly></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="资源编号" prop="equip_id"> <FormItem label="资源编号" prop="equip_id">
<Input v-model="formItem.equip_id" placeholder="请输入设备编号" readonly></Input> <Input v-model="formItem.equip_id" placeholder="请输入设备编号" readonly></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="工作日历" prop="work"> <FormItem label="工作日历" prop="work">
<Select v-model="formItem1.calendarwork_pk" clearable placeholder="请选择..."> <Select v-model="formItem1.calendarwork_pk" filterable clearable placeholder="请选择...">
<Option v-for="item in workList" :value="item.id" :key="item.calName">{{ item.calName }}</Option> <Option v-for="item in workList" :value="item.id" :key="item.calName">{{ item.calName }}</Option>
</Select> </Select>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="加班日历" prop="overtime"> <FormItem label="加班日历" prop="overtime">
<Select v-model="formItem2.calendarovertime_pk" clearable placeholder="请选择..."> <Select v-model="formItem2.calendarovertime_pk" filterable clearable placeholder="请选择...">
<Option <Option v-for="item in overtimeList" :value="item.id" :key="item.holidayCalName">{{ item.holidayCalName }}</Option>
v-for="item in overtimeList" </Select>
:value="item.id"
:key="item.holidayCalName"
>{{ item.holidayCalName }}</Option>
</Select>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="是否关重" prop="isimportant"> <FormItem label="是否关重" prop="isimportant">
<RadioGroup v-model="formItem.isimportant"> <RadioGroup v-model="formItem.isimportant">
<Radio label="1"></Radio> <Radio label="1"></Radio>
<Radio label="2"></Radio> <Radio label="2"></Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem label="能力值" prop="capabilityValue"> <FormItem label="能力值" prop="capabilityValue">
<!-- <Input v-model="formItem.capabilityValue" placeholder="请输入能力值"></Input> --> <!-- <Input v-model="formItem.capabilityValue" placeholder="请输入能力值"></Input> -->
<InputNumber v-model="formItem.capabilityValue" :max="100" :min="1"></InputNumber> <InputNumber v-model="formItem.capabilityValue" :max="100" :min="1"></InputNumber>
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
<FormItem> <FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button> <Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button> <Button @click="handleClose" class="ml20">取消</Button>
</FormItem> </FormItem>
</Form> </Form>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
export default { export default {
name: "Edit", name: "Edit",
data() { data() {
return { return {
workList: [], workList: [],
overtimeList: [], overtimeList: [],
formItem: { formItem: {
equip_name: "", equip_name: "",
equip_id: "", equip_id: "",
isimportant: "1", isimportant: "1",
capabilityValue: "", capabilityValue: "",
}, },
formItem1: { formItem1: {
id: 0, id: 0,
equip_pk: 0, equip_pk: 0,
calendarwork_pk: 0, calendarwork_pk: 0,
}, },
formItem2: { formItem2: {
id: 0, id: 0,
equip_pk: 0, equip_pk: 0,
calendarovertime_pk: 0, calendarovertime_pk: 0,
}, },
entity: {}, entity: {},
rules: { rules: {
name: [{ required: true, message: "必填", trigger: "blur" }], name: [{
}, required: true,
}; message: "必填",
}, trigger: "blur"
props: { }],
eid: Number, },
}, };
created() {
this.laodaction();
},
methods: {
laodaction() {
let parmse = {
pageIndex: 1,
conditions: [],
pageSize: 10,
};
Api.create(parmse).then((r) => {
if (r.success) {
this.workList = r.result;
} else {
this.$Message.error("获取数据失败...");
}
});
Api.create1(parmse).then((r) => {
if (r.success) {
this.overtimeList = r.result;
} else {
this.$Message.error("获取数据失败...");
}
});
}, },
load(v) { props: {
Api.get({ id: v }).then((r) => { eid: Number,
this.formItem.equip_name = r.result.title;
this.formItem.equip_id = r.result.code;
this.formItem.capabilityValue = r.result.capabilityValue;
this.formItem1.calendarwork_pk = r.result.calKey;
this.formItem2.calendarovertime_pk = r.result.holidayKey;
this.formItem1.equip_pk = r.result.id;
this.formItem2.equip_pk = r.result.id;
if (r.result.isimportant) {
this.formItem.isimportant = r.result.isimportant + "";
} else {
this.formItem.isimportant = "1";
}
});
}, },
handleSubmit() { created() {
this.$refs.form.validate((v) => { this.laodaction();
if (v) {
Api.update({
equipCalendarWork: this.formItem1,
equipCalendarOverTime: this.formItem2,
isimportant: this.formItem.isimportant,
capabilityValue: this.formItem.capabilityValue,
})
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
}, },
handleClose() { methods: {
this.$emit("on-close"); laodaction() {
}, let parmse = {
l(key) { pageIndex: 1,
key = "plan_resource" + "." + key; conditions: [],
return this.$t(key); pageSize: 10,
};
Api.create(parmse).then((r) => {
if (r.success) {
this.workList = r.result;
} else {
this.$Message.error("获取数据失败...");
}
});
Api.create1(parmse).then((r) => {
if (r.success) {
this.overtimeList = r.result;
} else {
this.$Message.error("获取数据失败...");
}
});
},
load(v) {
Api.get({
id: v
}).then((r) => {
this.formItem.equip_name = r.result.title;
this.formItem.equip_id = r.result.code;
this.formItem.capabilityValue = r.result.capabilityValue;
this.formItem1.calendarwork_pk = r.result.calKey;
this.formItem2.calendarovertime_pk = r.result.holidayKey;
this.formItem1.equip_pk = r.result.id;
this.formItem2.equip_pk = r.result.id;
if (r.result.isimportant) {
this.formItem.isimportant = r.result.isimportant + "";
} else {
this.formItem.isimportant = "1";
}
});
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
Api.update({
equipCalendarWork: this.formItem1,
equipCalendarOverTime: this.formItem2,
isimportant: this.formItem.isimportant,
capabilityValue: this.formItem.capabilityValue,
})
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
l(key) {
key = "plan_resource" + "." + key;
return this.$t(key);
},
}, },
}, watch: {
watch: { eid(v) {
eid(v) { if (v != 0) {
if (v != 0) { this.formItem1.calendarwork_pk = "";
this.formItem1.calendarwork_pk = ""; this.formItem2.calendarovertime_pk = "";
this.formItem2.calendarovertime_pk = ""; this.load(v);
this.load(v); }
} },
}, },
},
}; };
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment