xy 2 years ago
parent c83d5b3646
commit a70cb5f965

@ -42,11 +42,6 @@ export const constantRoutes = [
component: () => import("@/views/404"),
hidden: true,
},
{
path: "/test",
component: () => import("@/views/component/test.vue"),
hidden: true,
},
{
path: "/info",
component: Layout,

@ -43,7 +43,12 @@
<tr>
<td>执行状态</td>
<td>
<template v-if="data.status !== 6">
<template v-if="data.status === 2">
<div class="btns">
<Button type="primary" @click="esignConfirm"></Button>
</div>
</template>
<template v-else-if="data.status !== 6">
<div class="sign-container">
<div v-if="data.act_start_time">
<div>
@ -118,18 +123,34 @@ export default {
this.data = data
},
async esignConfirm () {
const base64 = await this.$refs['esign'].generate({ format:'image/png', quality: 0.7 });
const file = base64toFile(base64,`${new Date().getTime()}.png`)
const form = new FormData();
form.append('file',file)
const fileInfo = await axios.post(process.env.VUE_APP_UPLOAD_API,form,{
headers: {
Authorization: "Bearer " + getToken()
}
})
let fileInfo;
if (this.data.status !== 2) {
const base64 = await this.$refs['esign'].generate({ format:'image/png', quality: 0.7 });
const file = base64toFile(base64,`${new Date().getTime()}.png`)
const form = new FormData();
form.append('file',file)
fileInfo = await axios.post(process.env.VUE_APP_UPLOAD_API,form,{
headers: {
Authorization: "Bearer " + getToken()
}
})
}
let copyData = deepCopy(this.data)
if (this.data.status === 2) {
copyData.status = 3;
for (let key in copyData) {
if (/_relation/g.test(key)) {
delete copyData[key]
}
}
save({
table_name: 'transfers',
...copyData
}).then(_ => {
})
}
if (this.data.status === 3) {
copyData.status = 4;
copyData.start_sign = fileInfo.data?.id;
copyData.act_start_time = this.$moment().format('YYYY-MM-DD HH:mm');

@ -13,8 +13,7 @@
<dv-border-box-13 style="width: 100%;height: 100%;min-height: .5px;" :style="{ 'opacity': heights[index] ? 1 : 0}">
<div style="width: 100%;height: 100%;padding: 30px 20px;line-height: 1;" class="d-flex flex-column jc-between flex-1">
<div class="board-item__top d-flex jc-between ai-center">
<dv-decoration-11 style="width: 160px;height: 48px;">{{typeMap.get(item.status)}}</dv-decoration-11>
<p class="fw-b equipment-name">{{ item.equipment_id_equipments_id_relation ? item.equipment_id_equipments_id_relation.name : '' }}</p>
<dv-decoration-11 style="width: 160px;height: 48px;">{{ item.equipment_id_equipments_id_relation ? item.equipment_id_equipments_id_relation.name : '' }}</dv-decoration-11>
</div>
<div class="board-item__bottom d-flex jc-between ai-start">
<div class="time-info">
@ -27,7 +26,7 @@
</div>
<div v-if="setTransferStatusNumber !== -1" @click.stop="showDetail(item)">
<dv-border-box-8 reverse class="fw-b text-center" style="width: 64px;height: 38px;line-height: 38px;cursor: pointer;"
>{{setStatusText}}</dv-border-box-8>
>{{setStatusText(item.status)}}</dv-border-box-8>
</div>
</div>
</div>
@ -201,8 +200,14 @@ export default {
},
computed: {
setStatusText () {
if (this.setTransferStatusNumber === 4) return '执行';
if (this.setTransferStatusNumber === 6) return '关闭';
return function (status) {
const textMap = new Map([
[2,'接收'],
[3,'确认'],
[4,'关闭']
])
return textMap.get(status)
}
},
lastTimeColor () {
return function (min) {

@ -1,32 +0,0 @@
<template>
<div>
123
<avue-input-map :params="mapparams" placeholder="请选择地图" v-model="mapform"></avue-input-map>
<xyTinymce v-model="content"></xyTinymce>
</div>
</template>
<script>
import AvueMap from 'avue-plugin-map'
import xyTinymce from "@/components/XyTinymce/index.vue";
export default{
components: {
AvueMap,
xyTinymce
},
data(){
return{
mapparams: {
zoom: 11,
},
mapform: [],
content:''
}
},
}
</script>
<style>
</style>

@ -10,14 +10,20 @@
:picker-options="pickerOptions"
placeholder="日期选择"
:format="createType === 1 ? 'yyyy-MM-dd' : 'yyyy第WW周'"
style="width: 160px;"
style="width: 160px"
@input="pickDate"
></el-date-picker>
<p style="margin-left: 14px">
您正在为
<span style="color: red">{{ date }}</span>
创建
<span style="color: red;"> {{ abilities.find(i => i.value === ability) ? abilities.find(i => i.value === ability).key : '' }} </span>
<span style="color: red">
{{
abilities.find((i) => i.value === ability)
? abilities.find((i) => i.value === ability).key
: ""
}}
</span>
调令
</p>
<!-- <el-radio-group size="small" style="margin-left: 14px;" v-model="createType">-->
@ -46,10 +52,14 @@
<div class="select-item">
<div class="select-item__title">选择类别</div>
<el-radio-group size="small" v-model="ability" @input="e => data.forEach(i => i.leibie = e)">
<el-radio-group
size="small"
v-model="ability"
@input="(e) => data.forEach((i) => (i.leibie = e))"
>
<el-radio-button v-for="item in abilities" :label="item.value">{{
item.key
}}</el-radio-button>
item.key
}}</el-radio-button>
</el-radio-group>
</div>
@ -57,10 +67,44 @@
<Button type="primary" style="margin-left: 10px" @click="clear"
>清空筛选</Button
>
<el-popover
placement="top-start"
title="模板"
width="300"
trigger="click"
@show="getTemplates"
>
<template>
<Table
:loading="templateLoading"
:data="templates"
size="small"
:columns="templateTable"
></Table>
<div style="display: flex; justify-content: center; padding: 8px 0">
<el-pagination
small
:current-page.sync="templateSelect.page"
:page-size="templateSelect.page_size"
layout="prev, pager, next"
:total="templateTotal"
@current-change="getTemplates"
>
</el-pagination>
</div>
</template>
<Button
slot="reference"
type="primary"
style="margin-left: 10px"
>模板选择</Button
>
</el-popover>
</div>
</div>
<Table
ref="dataTable"
style="margin-top: 20px"
:columns="columns"
:data="mergeData"
@ -84,36 +128,78 @@ import { mergeTableRow } from "@/utils/mergeTableRow";
import { show } from "@/api/system/customFormField";
export default {
inject: ["equipments"],
props: {
},
props: {},
data() {
return {
templateLoading: false,
templates: [],
templateTotal: 0,
templateSelect: {
table_name: "transfer_templates",
page: 1,
page_size: 20,
},
templateTable: [
{
type: "index",
width: 46,
title: " ",
},
{
title: "名称",
key: "name",
},
{
title: "操作",
key: "operate",
render: (h, { row }) =>
h(
"Button",
{
props: {
type: "primary",
size: "small",
},
on: {
["click"]: (_) => {
this.handleClone(JSON.parse(row.content))
},
},
},
"选择"
),
},
],
dispatches: [],
transferDispatches: [],
createType: 1,
pickerOptions: {
firstDayOfWeek: 1,
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
}
}, {
text: '明天',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() + 3600 * 1000 * 24);
picker.$emit('pick', date);
}
}, {
text: '下周',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
}
}]
shortcuts: [
{
text: "今天",
onClick(picker) {
picker.$emit("pick", new Date());
},
},
{
text: "明天",
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() + 3600 * 1000 * 24);
picker.$emit("pick", date);
},
},
{
text: "下周",
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
picker.$emit("pick", date);
},
},
],
},
areas: [],
types: [],
@ -135,7 +221,7 @@ export default {
end_time: "",
content: "",
level: 1,
leibie: this.ability
leibie: this.ability,
})) || [],
columns: [
// {
@ -152,119 +238,155 @@ export default {
render: (h, { row, index }) => {
let text = row.equipment ? row.equipment.name : "";
return h("div", [
h('el-popover',{
props: {
title: "今日调令",
width: "400px"
},
on: {
show: _ => {
this.transferDispatches = this.dispatches.filter(i => (i.equipment_id === row.equipment_id))
}
}
},[
h('span',{
slot: 'reference',
// props: {
// type: "ios-list-box"
// },
style: {
'border-radius': '100%',
'margin-right': '4px',
'cursor': 'pointer',
'width': '20px',
'height': '20px',
'display': 'inline-block',
'background': '#367bc7',
'color': '#fff'
}
},this.dispatches.reduce((pre,cur) => {
return cur.equipment_id === row.equipment_id ? ++pre : pre
},0)),
h('Table',{
style: {
'width': "480px"
h(
"el-popover",
{
props: {
placement: "top-start",
title: "今日调令",
width: "400px",
},
on: {
show: (_) => {
this.transferDispatches = this.dispatches.filter(
(i) => i.equipment_id === row.equipment_id
);
},
},
},
[
h(
"span",
{
slot: "reference",
// props: {
// type: "ios-list-box"
// },
style: {
"border-radius": "100%",
"margin-right": "4px",
cursor: "pointer",
width: "20px",
height: "20px",
display: "inline-block",
background: "#367bc7",
color: "#fff",
},
},
this.dispatches.reduce((pre, cur) => {
return cur.equipment_id === row.equipment_id
? ++pre
: pre;
}, 0)
),
h("Table", {
style: {
width: "480px",
},
props: {
size: "small",
data: this.transferDispatches,
columns: [
{
title: " ",
type: "index",
width: 46,
},
{
title: "开始时间",
key: "start_time",
align: "center",
render: (h, { row }) =>
h(
"span",
this.$moment(row.start_time).format(
"YYYY-MM-DD HH:mm"
)
),
},
{
title: "结束时间",
key: "end_time",
align: "center",
render: (h, { row }) =>
h(
"span",
this.$moment(row.end_time).format(
"YYYY-MM-DD HH:mm"
)
),
},
{
title: "内容",
key: "content",
},
],
},
}),
]
),
h("span", text),
h(
"Button",
{
props: {
size: "small",
data: this.transferDispatches,
columns: [
{
title: " ",
type: "index",
width: 46
},
{
title: '开始时间',
key: 'start_time',
align: 'center',
render:(h, { row }) => (h('span',this.$moment(row.start_time).format('YYYY-MM-DD HH:mm')))
},
{
title: '结束时间',
key: 'end_time',
align: 'center',
render:(h, { row }) => (h('span',this.$moment(row.end_time).format('YYYY-MM-DD HH:mm')))
},
{
title: '内容',
key: 'content'
}
]
}
})
]),
h('span',text),
h('Button',{
props: {
size: 'small',
type: 'primary',
icon: 'ios-add'
},
style: {
'margin-left': '6px'
type: "primary",
icon: "ios-add",
},
style: {
"margin-left": "6px",
},
on: {
["click"]: (e) => {
this.data.splice(index, 0, deepCopy(row));
},
},
},
on: {
['click']:e => {
this.data.splice(index,0,deepCopy(row))
}
}
},'新增')
"新增"
),
]);
},
},
{
title: '机组运行状态',
title: "机组运行状态",
width: 200,
render: (h,{ row }) => {
render: (h, { row }) => {
const create = () => {
let dom = [];
for (let i = 0;i<=row._random;i++) {
dom.push(h('div',{
style: {
width: '14px',
height: '14px',
background: i === row._random-1 ? 'red' : 'green',
'border-radius': '100%',
'margin-left': '6px'
}
}))
for (let i = 0; i <= row._random; i++) {
dom.push(
h("div", {
style: {
width: "14px",
height: "14px",
background: i === row._random - 1 ? "red" : "green",
"border-radius": "100%",
"margin-left": "6px",
},
})
);
}
return dom;
}
return h('div',{
style: {
display: 'flex'
}
},create())
}
};
return h(
"div",
{
style: {
display: "flex",
},
},
create()
);
},
},
{
title: '类别',
key: 'yinpaishui',
title: "类别",
key: "yinpaishui",
width: 100,
align: 'center',
render: (h,{ row }) => (h('span',this.abilities.find(i => i.value === row.leibie)?.key))
align: "center",
render: (h, { row }) =>
h("span", this.abilities.find((i) => i.value === row.leibie)?.key),
},
{
title: "开启时间",
@ -278,23 +400,30 @@ export default {
type: "time",
size: "small",
transfer: true,
format: "HH:mm"
format: "HH:mm",
},
on: {
["on-change"]: (e) => {
this.data[index].start_time = e
this.data[index].start_time = e;
if (this.data[index]._last) {
const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i))
const [hour, min] = this.data[index].start_time
.split(":")
.map((i) => Number(i));
let addTime = {
hour: Math.floor(this.data[index]._last),
min: (this.data[index]._last % 1) * 60
}
min: (this.data[index]._last % 1) * 60,
};
let resTime = {
hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0),
min: (min + addTime.min) % 60
}
this.data[index].end_time = `${resTime.hour}:${resTime.min}`
hour:
hour + addTime.hour + (min + addTime.min >= 60 ? 1 : 0),
min: (min + addTime.min) % 60,
};
this.data[index].end_time = `${resTime.hour
.toString()
.padStart(2, "0")}:${resTime.min
.toString()
.padStart(2, "0")}`;
}
},
},
@ -306,32 +435,48 @@ export default {
width: 140,
align: "center",
key: "last",
render: (h,{ row, index }) => {
return h('InputNumber',{
render: (h, { row, index }) => {
const getValue = () => {
if (row.start_time && row.end_time) {
const [start_hour,start_min] = row.start_time.split(':')
const [end_hour,end_min] = row.end_time.split(':')
const diffMins = (Number(end_hour) - Number(start_hour)) * 60 + (Number(end_min) - Number(start_min))
return diffMins / 60
}
return 0
}
return h("InputNumber", {
props: {
value: 0,
value: getValue(),
min: 0,
step: 0.5,
size: "small",
precision: 1
precision: 1,
},
on: {
['on-change']:e => {
this.data[index]._last = e
const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i))
["on-change"]: (e) => {
this.data[index]._last = e;
const [hour, min] = this.data[index].start_time
.split(":")
.map((i) => Number(i));
let addTime = {
hour: Math.floor(e),
min: (e % 1) * 60
}
min: (e % 1) * 60,
};
let resTime = {
hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0),
min: (min + addTime.min) % 60
}
this.data[index].end_time = `${resTime.hour}:${resTime.min}`
}
}
})
}
hour:
hour + addTime.hour + (min + addTime.min >= 60 ? 1 : 0),
min: (min + addTime.min) % 60,
};
this.data[index].end_time = `${resTime.hour
.toString()
.padStart(2, "0")}:${resTime.min
.toString()
.padStart(2, "0")}`;
},
},
});
},
},
{
title: "结束时间",
@ -345,7 +490,7 @@ export default {
type: "time",
size: "small",
transfer: true,
format: "HH:mm"
format: "HH:mm",
},
on: {
["on-change"]: (e) => (this.data[index].end_time = e),
@ -451,33 +596,91 @@ export default {
};
},
methods: {
clone () {
let verify = true;
const submitData = this.data.filter(i => (i.start_time || i.end_time || i.content));
submitData.forEach(item => {
if (!item.start_time || !item.end_time || !item.level) {
handleClone (content) {
if (!content) return;
const groupTemplateData = new Map();
content.sort((a, b) => a.equipment_id - b.equipment_id)
.forEach(item => {
const group = groupTemplateData.get(item.equipment_id) || [];
group.push(item);
groupTemplateData.set(item.equipment_id, group);
});
const dataMap = new Map(this.data.map((item, index) => [item.equipment_id, index]));
groupTemplateData.forEach((group, equipment_id) => {
const findIndex = dataMap.get(equipment_id);
if (findIndex !== undefined) {
const findData = this.data[findIndex];
this.data.splice(findIndex, 0, ...group.map(i => ({ ...findData, ...i })));
}
});
},
async getTemplates() {
this.templateLoading = true;
const res = await index(this.templateSelect);
this.templates = res.data;
this.templateTotal = res.total;
this.templateLoading = false;
},
clone() {
const submitData = this.data.filter(
(i) => i.start_time || i.end_time || i.content
);
let verify = submitData.length > 0;
submitData.forEach((item) => {
if (!item.start_time || !item.end_time) {
verify = false;
}
})
});
if (!verify) {
this.$message({
type: 'warning',
message: '请填写完整信息'
})
return
type: "warning",
message: "请填写完整信息",
});
return;
}
submitData.forEach(i => {
delete i['equipment_id-span']
delete i['_index']
delete i['_rowKey']
})
console.log(JSON.stringify(submitData))
submitData.forEach((i) => {
delete i["equipment_id-span"];
delete i["_index"];
delete i["_rowKey"];
});
this.$prompt("请输入模板名称", "模板", {
confirmButtonText: "确定",
cancelButtonText: "取消",
inputValidator: (value) => {
return !!value;
},
inputErrorMessage: "请输入模板名称",
}).then(({ value }) => {
save({
table_name: "transfer_templates",
name: value,
content: JSON.stringify(
submitData.map((i) => ({
equipment_id: i.equipment_id,
start_time: i.start_time,
end_time: i.end_time,
content: i.content,
level: i.level,
}))
),
}).then((_) => {
this.$message({
type: "success",
message: "保存成功",
});
});
});
},
clear () {
clear() {
this.select = {
area: [],
type: []
type: [],
};
},
@ -488,7 +691,7 @@ export default {
}
},
reset () {
reset() {
this.clear();
this.data =
this.equipmentList?.map((i) => ({
@ -498,76 +701,92 @@ export default {
end_time: "",
content: "",
level: 1,
leibie: this.ability
leibie: this.ability,
})) || [];
},
submit () {
let verify = true;
const submitData = this.data.filter(i => (i.start_time || i.end_time || i.content));
submitData.forEach(item => {
submit() {
const submitData = this.data.filter(
(i) => i.start_time || i.end_time || i.content
);
let verify = submitData.length > 0;
submitData.forEach((item) => {
if (!item.start_time || !item.end_time || !item.level) {
verify = false;
}
})
});
if (!verify) {
this.$message({
type: 'warning',
message: '请填写完整信息'
})
return
type: "warning",
message: "请填写完整信息",
});
return;
}
const uid = uuid();
let promiseAll = [];
submitData.forEach(i => {
delete i['equipment_id-span']
delete i['_index']
delete i['_rowKey']
submitData.forEach((i) => {
delete i["equipment_id-span"];
delete i["_index"];
delete i["_rowKey"];
if (this.createType === 2) {
const startDay = this.$moment(this.date).startOf('week')
const startDay = this.$moment(this.date).startOf("week");
let weekArr = [];
for(let a = 1;a <= 7;a++) {
weekArr.push(this.$moment(startDay).add(a,'days').format('YYYY-MM-DD'))
for (let a = 1; a <= 7; a++) {
weekArr.push(
this.$moment(startDay).add(a, "days").format("YYYY-MM-DD")
);
}
weekArr.forEach(j => {
promiseAll.push(save({
...i,
table_name: 'transfers',
start_time: `${j} ${i.start_time}`,
end_time: `${j} ${i.end_time}`,
no: uid,
status: 1
},false))
})
weekArr.forEach((j) => {
promiseAll.push(
save(
{
...i,
table_name: "transfers",
start_time: `${j} ${i.start_time}`,
end_time: `${j} ${i.end_time}`,
no: uid,
status: 1,
},
false
)
);
});
} else {
i.start_time = `${this.date} ${i.start_time}`;
i.end_time = `${this.date} ${i.end_time}`;
i.no = uid;
i.status = 1;
promiseAll.push(save({
table_name: 'transfers',
...i
},false))
promiseAll.push(
save(
{
table_name: "transfers",
...i,
},
false
)
);
}
})
});
let loadingInstance = this.$loading({
lock:true,
background:"rgba(0,0,0,0.4)",
text:"正在加载中..."
})
Promise.all(promiseAll).then(res => {
this.reset();
loadingInstance.close();
this.$message({
type: 'success',
message: `成功创建${res.length}条调令`
lock: true,
background: "rgba(0,0,0,0.4)",
text: "正在加载中...",
});
Promise.all(promiseAll)
.then((res) => {
this.reset();
loadingInstance.close();
this.$message({
type: "success",
message: `成功创建${res.length}条调令`,
});
this.$bus.$emit("createdTransfer");
})
this.$bus.$emit('createdTransfer')
}).catch(_ => {
loadingInstance.close();
})
.catch((_) => {
loadingInstance.close();
});
},
async getArea() {
@ -583,7 +802,7 @@ export default {
});
}
}
this.$bus.$emit('areas',this.areas)
this.$bus.$emit("areas", this.areas);
},
async getType() {
const obj = (await show({ id: 1 }, false))?.select_item;
@ -599,7 +818,7 @@ export default {
}
}
},
async getAbility () {
async getAbility() {
const obj = (await show({ id: 31 }, false))?.select_item;
if (obj && typeof obj === "object") {
let keys = Object.keys(obj);
@ -612,12 +831,12 @@ export default {
});
}
}
this.$bus.$emit('yinpaishui',this.abilities)
this.$bus.$emit("yinpaishui", this.abilities);
},
pickDate () {
this.$bus.$emit('pickDate',this.date)
}
pickDate() {
this.$bus.$emit("pickDate", this.date);
},
},
computed: {
mergeData() {
@ -633,7 +852,7 @@ export default {
},
equipmentList() {
return this.equipments() || [];
}
},
},
watch: {
equipmentList(val) {
@ -646,8 +865,9 @@ export default {
content: "",
level: 1,
leibie: this.ability,
_random: Math.round(Math.random() * 8)
_random: Math.round(Math.random() * 8),
})) || [];
this.handleClone(this.$route.params.cloneTransfer)
},
select: {
handler: function (val) {
@ -655,45 +875,56 @@ export default {
let list1 = [];
let list2 = [];
if (val.area.length > 0) {
list1 = this.equipments().filter(i => val.area.find(j => j === i.area))
list1 = this.equipments().filter((i) =>
val.area.find((j) => j === i.area)
);
}
if (val.type.length > 0) {
list2 = this.equipments().filter(i => val.type.find(j => j === i.type))
list2 = this.equipments().filter((i) =>
val.type.find((j) => j === i.type)
);
}
this.data = Array.from(new Set([...list1,...list2].map(JSON.stringify))).map(JSON.parse).map((i) => ({
equipment: i,
equipment_id: i.id,
start_time: "",
end_time: "",
content: "",
level: 1,
leibie: this.ability
})) || [];
this.data =
Array.from(new Set([...list1, ...list2].map(JSON.stringify)))
.map(JSON.parse)
.map((i) => ({
equipment: i,
equipment_id: i.id,
start_time: "",
end_time: "",
content: "",
level: 1,
leibie: this.ability,
})) || [];
} else {
this.data = this.equipments()?.map((i) => ({
equipment: i,
equipment_id: i.id,
start_time: "",
end_time: "",
content: "",
level: 1,
leibie: this.ability
})) || [];
this.data =
this.equipments()?.map((i) => ({
equipment: i,
equipment_id: i.id,
start_time: "",
end_time: "",
content: "",
level: 1,
leibie: this.ability,
})) || [];
}
},
deep: true
}
deep: true,
},
},
mounted() {},
created() {
this.$bus.$on("getDispatches", dispatches => (this.dispatches = dispatches))
this.$bus.$on(
"getDispatches",
(dispatches) => (this.dispatches = dispatches)
);
this.getArea();
this.getType();
this.getAbility();
},
destroyed() {
this.$bus.$off("getDispatches")
}
this.$bus.$off("getDispatches");
},
};
</script>
@ -727,7 +958,6 @@ export default {
}
}
.btns {
margin-top: 10px;
padding-left: 10px;
}

@ -173,12 +173,12 @@ export default {
cancelButtonText: '取消',
inputType: 'textarea',
closeOnClickModal: false,
inputPlaceholder: '点位 开始时间 结束时间 调令内容,\n点位 开始时间 结束时间 调令内容 \n每个值以空格隔开每条调令用","(英文逗号)分割',
inputPlaceholder: '点位 开始时间 结束时间 调令内容,\n点位 开始时间 结束时间 调令内容 \n每个值以空格隔开每条调令用","分割',
beforeClose:(action, instance, done) => {
if (action === 'confirm') {
let value = instance._data.inputValue;
try {
let group = value.split(',').map(i => i.replace(/\n/g,''));
let group = value.split(/,|/).map(i => i.replace(/\n/g,''));
group.forEach((item,index) => {
let dataArr = item.split(/\s+/);
if (!this.equipments.find(i => i.name === dataArr[0])) {

@ -40,14 +40,18 @@ export default {
},
computed: {},
mounted() {
this.$confirm('选择调令创建方式','调令方式',{
confirmButtonText: '快速调令',
cancelButtonText: '普通调令',
type: 'info',
closeOnPressEscape: false,
closeOnClickModal: false,
showClose: false
}).then(_ => this.isQuick = true).catch(_ => this.isQuick = false)
if (this.$route.params.cloneTransfer) {
this.isQuick = false
} else {
this.$confirm('选择调令创建方式','调令方式',{
confirmButtonText: '快速调令',
cancelButtonText: '普通调令',
type: 'info',
closeOnPressEscape: false,
closeOnClickModal: false,
showClose: false
}).then(_ => this.isQuick = true).catch(_ => this.isQuick = false)
}
},
created() {
this.getEquipments();

@ -0,0 +1,755 @@
<template>
<div>
<!-- 查询配置 -->
<div>
<div ref="lxHeader">
<LxHeader
icon="md-apps"
:text="$route.meta.title"
style="margin-bottom: 10px; border: 0px; margin-top: 15px"
>
<div slot="content"></div>
<slot>
<header-content :auths="auths_auth_mixin">
<template #search>
<div style="display: flex">
<Select
v-model="select.filter[0].key"
style="width: 100px"
placeholder="搜索条目"
>
<Option
v-for="item in form"
:key="item.id"
:value="item.field"
>{{ item.name }}</Option
>
</Select>
<Select
v-model="select.filter[0].op"
style="width: 100px; margin-left: 10px"
placeholder="搜索条件"
>
<Option
v-for="item in op"
:key="item.value"
:value="item.value"
>{{ item.label }}</Option
>
</Select>
<template
v-if="
select.filter[0].op !== 'range' &&
!columnArrTest(select.filter[0].key)
"
>
<Input
v-model="select.filter[0].value"
style="width: 150px; margin-left: 10px"
placeholder="请填写关键词"
/>
</template>
<template
v-else-if="
select.filter[0].op !== 'range' &&
columnArrTest(select.filter[0].key)
"
>
<Select
v-model="select.filter[0].value"
style="width: 150px; margin-left: 10px"
placeholder="请选择关键词"
>
<Option
v-for="item in getColumnParams(select.filter[0].key)"
:key="item.id"
:value="
getColumnField(select.filter[0].key)._relations
? item[
getColumnField(select.filter[0].key)._relations
.foreign_key
]
: item.value
"
>{{
item.key ||
item.value ||
item.name ||
item.no ||
item.mingcheng ||
item.id
}}</Option
>
</Select>
</template>
<template v-else>
<Input
:value="select.filter[0].value.split(',')[0]"
style="width: 150px; margin-left: 10px"
placeholder="范围开始关键词"
@input="(e) => inputStartHandler(e, select.filter[0])"
/>
<span
style="
margin-left: 10px;
display: flex;
align-items: center;
"
></span
>
<Input
:value="select.filter[0].value.split(',')[1]"
style="width: 150px; margin-left: 10px"
placeholder="范围结束关键词"
@input="(e) => inputEndHandler(e, select.filter[0])"
/>
</template>
<Button
style="margin-left: 10px"
type="primary"
@click="$refs['xyTable'].getTableData(true)"
>查询</Button
>
<xy-selectors
style="margin-left: 10px"
@reset="reset"
@search="$refs['xyTable'].getTableData(true)"
>
<template>
<div class="select">
<div
class="select__item"
v-for="(item, index) in select.filter"
:key="`${item.value}-${index}`"
>
<p>条件{{ index + 1 }}</p>
<Select
v-model="item.key"
style="width: 100px"
placeholder="搜索条目"
>
<Option
v-for="item in form"
:key="item.id"
:value="item.field"
>{{ item.name }}</Option
>
</Select>
<Select
v-model="item.op"
style="width: 100px; margin-left: 10px"
placeholder="搜索条件"
>
<Option
v-for="item in op"
:key="item.value"
:value="item.value"
>{{ item.label }}</Option
>
</Select>
<template
v-if="
item.op !== 'range' && !columnArrTest(item.key)
"
>
<Input
v-model="item.value"
style="width: 150px; margin-left: 10px"
placeholder="请填写关键词"
/>
</template>
<template
v-else-if="
item.op !== 'range' && columnArrTest(item.key)
"
>
<Select
v-model="item.value"
style="width: 150px; margin-left: 10px"
placeholder="请选择关键词"
>
<Option
v-for="item in getColumnParams(item.key)"
:key="item.id"
:value="
getColumnField(item.key)._relations
? item[
getColumnField(item.key)._relations
.foreign_key
]
: item.value
"
>{{
item.key ||
item.value ||
item.name ||
item.no ||
item.mingcheng ||
item.id
}}</Option
>
</Select>
</template>
<template v-else>
<Input
:value="item.value.split(',')[0]"
style="width: 150px; margin-left: 10px"
placeholder="范围开始关键词"
@input="(e) => inputStartHandler(e, item)"
/>
<span style="margin-left: 10px"></span>
<Input
:value="item.value.split(',')[1]"
style="width: 150px; margin-left: 10px"
placeholder="范围结束关键词"
@input="(e) => inputEndHandler(e, item)"
/>
</template>
<el-button
v-if="index !== 0"
size="small"
type="danger"
icon="el-icon-delete"
circle
style="margin-left: 10px"
@click="select.filter.splice(index, 1)"
></el-button>
</div>
</div>
<div class="add-btn">
<el-button
size="small"
type="primary"
icon="el-icon-plus"
circle
@click="
select.filter.push({ key: '', op: '', value: '' })
"
></el-button>
<span>新增一条</span>
</div>
</template>
</xy-selectors>
</div>
</template>
<template #create>
<Button
type="primary"
@click="
$refs['dialog'].setType('add'), $refs['dialog'].show()
"
>新增</Button
>
</template>
<template #import>
<Button type="primary" @click="$refs['imports'].show()"
>导入</Button
>
</template>
<template #export>
<Button
type="primary"
@click="exportExcel(new Date().getTime().toString())"
>导出</Button
>
</template>
<Button type="primary" @click="cloneTransfer"></Button>
</header-content>
</slot>
</LxHeader>
</div>
</div>
<!--$refs['drawer'].setId(row.id);
$refs['drawer'].show();-->
<xy-table
:btn-width="240"
:auths="auths_auth_mixin"
:delay-req="true"
:destroy-action="destroy"
ref="xyTable"
:border="true"
:action="index"
:req-opt="tableSelect"
:destroy-req-opt="select"
:table-item="table"
@detail="
(row) => {
$router.push({
path: $route.path + '/detail/' + row.id,
});
}
"
@editor="
(row) => {
$refs['dialog'].setId(row.id);
$refs['dialog'].setType('editor');
$refs['dialog'].show();
}
"
>
<template #callback="{ row }">
<Button
size="small"
type="primary"
@click="
$refs['callback'].setId(row.id),
$refs['callback'].setType('add'),
$refs['callback'].show()
"
>反馈</Button
>
</template>
<template #distribute="{ row }">
<Button
v-if="row.status === 1"
size="small"
type="primary"
@click="setTransferStatus(2,row)"
>下发</Button
>
<Button
v-if="row.status === 2"
size="small"
type="primary"
ghost
@click="setTransferStatus(1,row)"
>取消</Button
>
</template>
</xy-table>
<dialoger
:table-name="customForm.tableName"
:form-info="form"
ref="dialog"
@refresh="$refs['xyTable'].getTableData()"
>
</dialoger>
<drawer
:table-name="customForm.tableName"
:form-info="form"
ref="drawer"
></drawer>
<imports
:table-name="customForm.tableName"
:form-info="form"
ref="imports"
@refresh="$refs['xyTable'].getTableData()"
></imports>
<callback ref="callback"></callback>
</div>
</template>
<script>
import { index as fieldIndex } from "@/api/system/customFormField";
import { authMixin } from "@/mixin/authMixin";
import { index, destroy, save } from "@/api/system/baseForm";
import { op } from "@/const/op";
import { download } from "@/utils/downloadRequest";
import { getparameter } from "@/api/system/dictionary";
import { show } from "@/api/system/customForm";
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
import { listdept } from "@/api/system/department";
import dialoger from "@/views/component/dialog.vue";
import LxHeader from "@/components/LxHeader/index.vue";
import headerContent from "@/components/LxHeader/XyContent.vue";
import drawer from "@/views/component/drawer.vue";
import imports from "@/views/component/imports.vue";
import callback from "@/views/order/component/callback.vue";
import {deepCopy} from "@/utils";
export default {
components: {
LxHeader,
dialoger,
headerContent,
drawer,
imports,
callback,
},
mixins: [authMixin],
provide: {
formStore: () => this.form,
},
data() {
return {
op,
select: {
table_name: "",
filter: [
{
key: "",
op: "",
value: "",
},
],
},
selectQuery: [],
form: [],
table: [],
customForm: {
customFormId: "",
tableName: "",
},
};
},
methods: {
cloneTransfer () {
this.$router.push({
name: 'menu_14',
params: {
cloneTransfer: this.$refs['xyTable'].getSelection().map(i => ({
equipment_id: i.equipment_id,
start_time: this.$moment(i.start_time).format('HH:mm'),
end_time: this.$moment(i.end_time).format('HH:mm'),
content: i.content,
level: i.level,
}))
}
})
},
setTransferStatus (status,row) {
let copyRow = deepCopy(row);
copyRow.status = status;
for (let key in copyRow) {
if (/_relation/g.test(key)) {
delete copyRow[key]
}
}
console.log(copyRow)
save({
table_name: 'transfers',
...copyRow
}).then(_ => this.$refs['xyTable'].getTableData())
},
index,
destroy,
download,
reset() {
this.select.filter.splice(1);
this.select.filter[0] = {
key: "",
op: "",
value: "",
};
},
async exportExcel(sheetName) {
const res = await index(
Object.assign(this.select, { page: 1, page_size: 9999 })
);
if (res.data) {
let headers = this.form.map((i) => {
return {
key: i.field,
title: i.name,
};
});
const data = res.data.map((row) =>
headers.map((header) => row[header.key])
);
data.unshift(headers.map((header) => header.title));
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, sheetName);
const wbout = XLSX.write(wb, {
bookType: "xlsx",
bookSST: true,
type: "array",
});
saveAs(
new Blob([wbout], { type: "application/octet-stream" }),
`${sheetName}.xlsx`
);
}
},
//target
inputStartHandler(e, target) {
let temp = target?.value.split(",")[1];
target.value = `${e},${temp ? temp : ""}`;
},
inputEndHandler(e, target) {
let temp = target?.value.split(",")[0];
target.value = `${temp ? temp : ""},${e}`;
},
async getFormDetail() {
if (this.$route.meta.params?.custom_form) {
let decode = decodeURIComponent(this.$route.meta.params?.custom_form);
try {
let custom_form = JSON.parse(decode);
this.customForm.customFormId = custom_form.custom_form_id;
this.customForm.tableName = custom_form.table_name;
this.select.table_name = custom_form.table_name;
} catch (err) {
console.warn(err);
}
}
if (this.$route.meta.params?.select) {
try {
this.selectQuery = JSON.parse(
decodeURIComponent(this.$route.meta.params?.select)
);
} catch (err) {
console.warn(err);
}
}
const res = await show({ id: this.customForm.customFormId }, false);
//
//
let baseTable = new Map([
[
"departments",
async () => {
const res = await listdept();
return res;
},
],
["admins", []],
]);
let { fields, relation } = res;
let fieldRes = fields.sort((a, b) => a.sort - b.sort);
if (
!fields ||
!relation ||
!fields instanceof Array ||
!relation instanceof Array
) {
throw new Error("fields或relation格式错误");
}
fieldRes?.forEach((i, index) => {
i._relations = relation.find((j) => j.custom_form_field === i.field);
if (i.select_item && typeof i.select_item === "object") {
let keys = Object.keys(i.select_item);
if (keys.length > 0) {
i._params = keys.map((key) => {
return {
key,
value: /^\d*$/.test(i.select_item[key])
? Number(i.select_item[key])
: i.select_item[key],
};
});
}
}
if (i.edit_input === "file" || i.edit_input === "files") {
return;
}
if (i._relations) {
if (baseTable.get(i._relations.link_table_name)) {
baseTable
.get(i._relations.link_table_name)()
.then((res) => (i._params = res));
} else {
i._params = i._relations.parameter_id
? getparameter({ id: i._relations.parameter_id }, false).then(
(res) => {
i._params = res.detail;
}
)
: this.index({
table_name: i._relations.link_table_name,
page: 1,
page_size: 9999,
}).then((res) => {
i._params = res.data;
});
}
}
});
this.form = fields;
console.log(111, this.form);
this.form
?.filter((i) => i.list_show)
.forEach((i) => {
let linkOb = {};
if (i.edit_input === "richtext") {
linkOb.customFn = (row) => {
return (
<div
style={{ "max-height": "55px", overflow: "scroll" }}
domPropsInnerHTML={row[i.field]}
></div>
);
};
}
if (
i.select_item &&
typeof i.select_item === "object" &&
!(i.select_item instanceof Array)
) {
let keys = Object.keys(i.select_item);
linkOb.customFn = (row) => {
let paramMap = new Map();
keys.forEach((key) => {
paramMap.set(i.select_item[key], key);
});
return <span>{paramMap.get(row[i.field]?.toString())}</span>;
};
}
if (i._relations) {
let { link_relation, foreign_key, link_with_name } = i._relations;
if (link_relation === "newHasOne" || link_relation === "hasOne") {
linkOb.customFn = (row) => {
if (i.edit_input === "file") {
return (
<a
download={row[link_with_name]?.original_name}
href={row[link_with_name]?.url}
>
{row[link_with_name]?.original_name}
</a>
);
} else {
return (
<span>
{row[link_with_name]?.name ||
row[link_with_name]?.no ||
row[link_with_name]?.value}
</span>
);
}
};
}
if (link_relation === "hasMany" || link_relation === "newHasMany") {
linkOb.customFn = (row) => {
if (i.edit_input === "files") {
return (
<div style="display: flex;flex-direction: column;">
{row[link_with_name]?.map((o) => (
<a>{o?.original_name || o?.name}</a>
))}
</div>
);
} else {
return (
<div>
{row[link_with_name]?.map((o) => (
<p>
{o?.name ||
o?.no ||
o?.value ||
o?.biaoti ||
o?.mingcheng}
</p>
))}
</div>
);
}
};
}
}
let alignLeft = [];
this.table.push(
Object.assign(
{
prop: i.field,
label: i.name,
width: i.width,
align: alignLeft.find((m) => m === i.field) ? "left" : "center",
fixed: i.is_fixed,
},
linkOb
)
);
});
this.table.unshift({
type: "index",
width: 60,
label: "序号",
});
this.table.unshift({
type: "selection",
width: 46,
reserveSelection: true
})
},
},
computed: {
columnArrTest() {
return function (field) {
return this.form.find((i) => i.field === field)
? this.form.find((i) => i.field === field).search_input ===
"checkbox" ||
this.form.find((i) => i.field === field).search_input === "radio"
: false;
};
},
getColumnField() {
return function (field) {
return this.form.find((i) => i.field === field)
? this.form.find((i) => i.field === field)
: {};
};
},
getColumnParams() {
return function (field) {
return this.form.find((i) => i.field === field)
? this.form.find((i) => i.field === field)._params
: [];
};
},
tableSelect() {
let filter = [...this.select.filter, ...this.selectQuery];
return {
...this.select,
filter,
};
},
},
created() {
this.getFormDetail();
},
};
</script>
<style scoped lang="scss">
.select {
&__item {
& > p {
display: inline-block;
width: 80px;
text-align: center;
}
& + div {
margin-top: 6px;
}
}
}
.add-btn {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
& > span {
padding: 0 10px;
}
}
a {
color: red;
text-decoration: none;
transition: all 0.2s;
}
a:hover {
color: red;
text-decoration: underline;
}
</style>
Loading…
Cancel
Save