xy 2 years ago
parent ff9f1cede8
commit a3f4bb3086

@ -0,0 +1,558 @@
<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 clearable v-model="select.filter[2].value" placeholder="请选择类型" style="width: 140px;" @on-change="e => !e ? select.filter[2].value = '' : ''">
<Option v-for="item in Array.from(types)" :value="item[0]">{{ item[1] }}</Option>
</Select>
<Select clearable v-model="select.filter[1].value" placeholder="请选择范围" style="width: 140px;margin-left: 6px;" @on-change="e => !e ? select.filter[1].value = '' : ''">
<Option v-for="item in Array.from(areas)" :value="item[0]">{{ item[1] }}</Option>
</Select>
<Input clearable v-model="select.filter[0].value" placeholder="关键词" style="width: 140px;margin-left: 6px;"/>
<Button
style="margin-left: 10px"
type="primary"
@click="$refs['xyTable'].getTableData(true)"
>查询</Button
>
</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>
</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>
<callback ref="callback"></callback>
</div>
</template>
<script>
import { index as fieldIndex,show as fieldShow } 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 callback from "@/views/order/component/callback.vue";
import {deepCopy} from "@/utils";
export default {
components: {
LxHeader,
dialoger,
headerContent,
drawer,
callback,
},
mixins: [authMixin],
provide: {
formStore: () => this.form,
},
data() {
return {
op,
select: {
table_name: "",
filter: [
{
key: "name",
op: "like",
value: "",
},
{
key: "area",
op: "eq",
value: "",
},
{
key: "type",
op: "eq",
value: "",
}
],
},
types: new Map(),
areas: new Map(),
selectQuery: [],
form: [],
table: [],
customForm: {
customFormId: "",
tableName: "",
},
};
},
methods: {
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: "序号",
});
},
async getArea() {
const obj = (await fieldShow({ id: 4 }, false))?.select_item;
if (obj && typeof obj === "object") {
let keys = Object.keys(obj);
if (keys.length > 0) {
this.areas = new Map(keys.map((key) => [/^\d*$/.test(obj[key]) ? Number(obj[key]) : obj[key],key]));
}
}
},
async getType() {
const obj = (await fieldShow({ id: 1 }, false))?.select_item;
if (obj && typeof obj === "object") {
let keys = Object.keys(obj);
if (keys.length > 0) {
this.types = new Map(keys.map((key) => [/^\d*$/.test(obj[key]) ? Number(obj[key]) : obj[key],key]));
}
}
},
},
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.getType();
this.getArea();
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>

@ -64,6 +64,8 @@
<td>
<div
style="
max-height: 19vh;
overflow-y: scroll;
line-height: 2;
text-align: left;
padding: 10px;

@ -3,7 +3,13 @@
<h1 class="title">苏州河道处调度指令看板</h1>
<div class="bottom">
<div>{{ $moment(time).format('YYYY-MM-DD HH:mm:ss') }}</div>
<div>
<p style="font-size: 1.3rem;">
<span style="color:#f00;padding-right: 4px;">{{ refresh }}</span><span>秒刷新</span>
<Icon type="md-refresh-circle" class="refresh-icon" style="margin-left: 10px;font-size:1.7rem;cursor: pointer;" @click="refreshTransfer"/>
</p>
<p>{{ $moment(time).format('YYYY-MM-DD HH:mm:ss') }}</p>
</div>
<div>
<div style="cursor:pointer;" @click="$refs['tomorrow'].show()"> <i class="el-icon-d-arrow-right"></i></div>
@ -22,7 +28,7 @@ export default {
components: {
tomorrow
},
inject: ['nowTime'],
inject: ['nowTime','refreshTime','refreshList'],
data() {
return {
tomorrows: []
@ -56,6 +62,12 @@ export default {
computed: {
time () {
return this.nowTime()
},
refresh () {
return this.refreshTime()
},
refreshTransfer () {
return this.refreshList
}
},
mounted() {
@ -96,4 +108,9 @@ export default {
}
}
$title-height: 8.46rem;
.refresh-icon:hover {
transition: all 1s;
transform: rotate(360deg);
}
</style>

@ -1,8 +1,8 @@
<template>
<div id="big-screen" ref="appRef">
<div class="refresh-time">
{{ refreshTime }}
</div>
<!-- <div class="refresh-time">-->
<!-- {{ refreshTime }}秒后刷新-->
<!-- </div>-->
<topBackground></topBackground>
<Title ref="title" @show-done="$refs['done'].show()" @step-click="stepClick"></Title>
<toDo ref="toDo"
@ -78,7 +78,9 @@ export default {
}
},
nowTime: () => this.time,
auths: () => this.auths_auth_mixin
auths: () => this.auths_auth_mixin,
refreshTime: () => this.refreshTime,
refreshList: () => this.getTransfer(true)
}
},
data() {
@ -166,8 +168,8 @@ export default {
table_name: "transfers",
page: 1,
page_size: 9999,
sort_name: "start_time",
sort_type: "asc",
sort_name: "created_at",
sort_type: "desc",
filter: [
{
key: 'start_time',
@ -309,8 +311,8 @@ export default {
position: relative;
.refresh-time {
font-size: 12px;
color: #fff;
font-size: 1.4rem;
color: #f00;
z-index: 3;
position: fixed;

@ -44,6 +44,7 @@
<div class="xy-table-item-label">调整类型 </div>
<div class="xy-table-item-content">
<el-select
:popper-append-to-body="false"
v-model="form.tiaozhengleixing"
clearable
placeholder="请选择调整类型"

@ -13,19 +13,6 @@
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>
调令
</p>
<!-- <el-radio-group size="small" style="margin-left: 14px;" v-model="createType">-->
<!-- <el-radio-button :label="1"></el-radio-button>-->
<!-- <el-radio-button :label="2"></el-radio-button>-->
@ -102,11 +89,13 @@
>模板选择</Button
>
</el-popover>
<Input v-model="select.name" style="width: 140px;margin-left: auto;" placeholder="点位名称"></Input>
<Input :value="select.name" style="width: 140px;margin-left: auto;" placeholder="点位名称" @on-change="nameInput"></Input>
</div>
</div>
<Table
draggable
@on-drag-drop="tableDrag"
ref="dataTable"
style="margin-top: 20px"
:columns="columns"
@ -127,7 +116,7 @@
import { equipmentInfos, checkTransfer } from "@/api/other"
import { uuid } from "@/utils";
import { index, save, destroy } from "@/api/system/baseForm";
import { deepCopy } from "@/utils";
import { deepCopy, debounce } from "@/utils";
import { mergeTableRow } from "@/utils/mergeTableRow";
import { show } from "@/api/system/customFormField";
export default {
@ -175,7 +164,7 @@ export default {
},
on: {
["click"]: (_) => {
this.handleClone(JSON.parse(row.content))
this.handleClone(JSON.parse(row.content),true)
},
},
},
@ -600,7 +589,8 @@ export default {
h("Select", {
props: {
value: this.data[index].leibie,
size: "small"
size: "small",
transfer: true
},
on: {
['on-change']:e => {
@ -623,7 +613,8 @@ export default {
h("Select", {
props: {
value: this.data[index].diaolingleixing,
size: "small"
size: "small",
transfer: true
},
on: {
['on-change']:e => {
@ -847,6 +838,34 @@ export default {
};
},
methods: {
nameInput: debounce(function (e) {
this.select.name = e.target.value;
}),
tableDrag (f, e) {
let first = parseInt(f)
let end = parseInt(e)
let tmp = this.data[first]
let len = 1;
let temps = [tmp]
while (tmp.equipment_id === this.data[first + len]?.equipment_id) {
temps.push(this.data[first + len])
len++;
}
if (first < end) {
this.data.splice(first, len)
this.data.splice(end-len+1, 0,...temps)
// for (let i = first + len; i <= end; i++) {
// this.data.splice(i - len, i === first + len ? len : 1, this.data[i])
// }
// this.data.splice(end, 1, ...temps)
}
if (first > end) {
for (let j = first; j > end; j--) {
this.data.splice(j, len, this.data[j - 1])
}
this.data.splice(end, 1, ...temps)
}
},
index,
async getEquipmentInfos () {
const res = await equipmentInfos({
@ -855,8 +874,25 @@ export default {
this.equipmentInfos = res
},
handleClone (content) {
handleClone (content,isTemplate=false) {
if (!content) return;
if (isTemplate) {
this.data =
content?.map((i) => ({
equipment: this.equipmentList.find((j) => j.id === i.equipment_id),
equipment_id: i.equipment_id,
start_time: i.start_time,
end_time: i.end_time,
content: i.content,
level: i.level,
kaiqishuliang: i.kaiqishuliang,
diaolingleixing: i.diaolingleixing,
leibie: i.leibie,
situations: this.equipmentList.find((j) => j.id === i.equipment_id)?.id_equip_situation_relations_equipment_id_relation
})) || [];
return
}
this.data =
this.equipmentList?.map((i) => ({
equipment: i,
@ -867,7 +903,7 @@ export default {
level: 1,
kaiqishuliang: 0,
diaolingleixing: "",
leibie: this.ability,
leibie: "",
situations: i.id_equip_situation_relations_equipment_id_relation
})) || [];
@ -945,6 +981,7 @@ export default {
level: i.level,
kaiqishuliang: i.kaiqishuliang,
diaolingleixing: i.diaolingleixing,
leibie: i.leibie
}))
),
}).then((_) => {
@ -981,15 +1018,17 @@ export default {
content: "",
level: 1,
kaiqishuliang: 0,
leibie: this.ability,
leibie: "",
situations: i.id_equip_situation_relations_equipment_id_relation
})) || [];
for (let key in this.$refs) {
if (/bengzhashuliang/g.test(key)) {
this.$refs[key].$children.forEach(i => i.currentValue = false)
this.$nextTick(() => {
for (let key in this.$refs) {
if (/bengzhashuliang/g.test(key)) {
this.$refs[key].$children.forEach(i => i.currentValue = false)
}
}
}
})
},
async submit() {
@ -1048,7 +1087,7 @@ export default {
delete i["_rowKey"];
i.start_time = `${this.date} ${i.start_time}`;
i.end_time = `${this.date} ${i.end_time}`;
i.end_time = i.end_time ? `${this.date} ${i.end_time}` : '';
i.no = uid;
i.status = 1;
@ -1056,7 +1095,8 @@ export default {
const res = await checkTransfer({
start_time: i.start_time,
end_time: i.end_time,
equipment_id: i.equipment_id
equipment_id: i.equipment_id,
diaolingleixing: i.diaolingleixing
})
promiseAll.push(
save(
@ -1197,7 +1237,12 @@ export default {
this.$bus.$emit("yinpaishui", this.abilities);
},
async getDiaolingleixing() {
const obj = (await show({ id: 85 }, false))?.select_item;
const obj = {
"逻辑调令": "4",
"防汛调令": "2",
"水环境调令": "1",
"船只过闸调令": "3"
};
if (obj && typeof obj === "object") {
let keys = Object.keys(obj);
if (keys.length > 0) {
@ -1244,7 +1289,7 @@ export default {
content: "",
level: 1,
kaiqishuliang: 0,
leibie: this.ability,
leibie: "",
situations: i.id_equip_situation_relations_equipment_id_relation
})) || [];
this.handleClone(this.$route.params.cloneTransfer)
@ -1281,7 +1326,7 @@ export default {
content: "",
level: 1,
kaiqishuliang: 0,
leibie: this.ability,
leibie: "",
situations: i.id_equip_situation_relations_equipment_id_relation
})) || [];
} else {
@ -1294,7 +1339,7 @@ export default {
content: "",
level: 1,
kaiqishuliang: 0,
leibie: this.ability,
leibie: "",
situations: i.id_equip_situation_relations_equipment_id_relation
})) || [];
}

Loading…
Cancel
Save