emis-frontend/src/views/system/sysZoneNav/navEditor.vue
2024-06-02 17:59:42 +08:00

395 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:sysZoneNav:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:sysZoneNav:remove']"
>删除</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="sysZoneNavList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" width="60">
<template slot-scope="scope">
<span v-text="getIndex(scope.$index)"> </span>
</template>
</el-table-column>
<el-table-column label="名称" align="left" prop="navName" min-width="180" />
<!-- <el-table-column label="父导航ID" align="center" prop="parentId" min-width="100" /> -->
<el-table-column label="排序" align="center" prop="orderNum" width="70">
<template slot-scope="scope">
<el-input
size="mini"
v-model="scope.row.orderNum"
@focus="rememberOldValue($event,scope)"
@blur="saveData($event,scope.row)"
@keyup="value=value.replace(/[^\d]/g,'')"
></el-input>
</template>
</el-table-column>
<el-table-column label="显示" align="center" prop="visible" width="75">
<template slot-scope="scope">
<el-switch
v-model="scope.row.visible"
:active-value="1"
:inactive-value="0"
@change="switchChange(scope.row)">
</el-switch>
</template>
</el-table-column>
<el-table-column label="url" align="left" prop="url" min-width="200" />
<!-- <el-table-column label="类型(0-初始 1-顶部导航 2-底部导航)" align="center" prop="navType" min-width="100" /> -->
<!-- <el-table-column label="显示状态(0显示 1隐藏)" align="center" prop="visible" min-width="100" /> -->
<!-- <el-table-column label="停用状态(0正常 1停用)" align="center" prop="status" min-width="100" /> -->
<!-- <el-table-column label="所属站点" align="center" prop="zoneId" min-width="100" /> -->
<!-- <el-table-column label="创建者" align="center" prop="createByName" min-width="100" /> -->
<!-- <el-table-column label="更新者" align="center" prop="updateByName" min-width="100" /> -->
<!-- <el-table-column label="备注" align="center" prop="remark" min-width="100" /> -->
<!-- <el-table-column label="创建时间" align="center" prop="createTime" min-width="170" /> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:sysZoneNav:edit']"
>修改</el-button>
<!-- <el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:sysZoneNav:remove']"
>删除</el-button> -->
</template>
</el-table-column>
</el-table>
<!-- 添加或修改站点导航链接对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="导航名称" prop="navName">
<el-input v-model="form.navName" placeholder="" />
</el-form-item>
<!-- <el-form-item label="父导航ID" prop="parentId">
<el-input v-model="form.parentId" placeholder="请输入父导航ID" />
</el-form-item> -->
<!-- <el-form-item label="显示顺序" prop="orderNum">
<el-input v-model="form.orderNum" placeholder="请输入显示顺序" />
</el-form-item> -->
<el-form-item label="url" prop="url">
<el-input v-model="form.url" placeholder="" />
</el-form-item>
<!-- <el-form-item label="类型(0-初始 1-顶部导航 2-底部导航)" prop="navType">
<el-input v-model="form.navType" placeholder="请输入类型(0-初始 1-顶部导航 2-底部导航)" />
</el-form-item>
<el-form-item label="显示状态(0显示 1隐藏)" prop="visible">
<el-input v-model="form.visible" placeholder="请输入显示状态(0显示 1隐藏)" />
</el-form-item>
<el-form-item label="停用状态(0正常 1停用)" prop="status">
<el-input v-model="form.status" placeholder="请输入停用状态(0正常 1停用)" />
</el-form-item> -->
<!-- <el-form-item label="所属站点" prop="zoneId">
<el-input v-model="form.zoneId" placeholder="" />
</el-form-item> -->
<!-- <el-form-item label="创建者" prop="createBy">
<el-input v-model="form.createBy" placeholder="请输入创建者" />
</el-form-item>
<el-form-item label="更新者" prop="updateByName">
<el-input v-model="form.updateBy" placeholder="请输入更新者" />
</el-form-item> -->
<!-- <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
</el-form-item> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listSysZoneNav, getSysZoneNav, delSysZoneNav, addSysZoneNav, updateSysZoneNav } from "@/api/system/sysZoneNav";
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
export default {
name: "sysZoneNav",
components: { elDateSimplePicker },
props:{
zoneId:undefined
},
dicts: [],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 搜索下拉
// itemOptions:[],
// 下拉枚举
// xxStatusOtions: [
// {value: '0', label: 'xx1'},
// {value: '10', label: 'xxx'},
// ],
// 总条数
total: 0,
// 站点导航链接表格数据
sysZoneNavList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 备注时间范围
daterangeCreateTime: [],
// 备注时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 1000,
id: null,
navName: null,
parentId: null,
orderNum: null,
url: null,
navType: null,
visible: null,
status: null,
zoneId: null,
createBy: null,
updateBy: null,
remark: null
},
// 表单参数
form: {},
// 表单校验
rules: {
navName: [
{ required: true, message: "导航名称不能为空", trigger: "blur" }
],
zoneId: [
{ required: true, message: "所属站点不能为空", trigger: "blur" }
],
}
};
},
watch: {
"zoneId": {
handler (newValue, oldValue) {
this.zoneId = newValue;
this.form.zoneId = newValue;
this.getList();
},
deep: true
}
},
created() {
this.getList();
},
methods: {
/** 查询站点导航链接列表 */
getList() {
this.loading = true;
this.queryParams.zoneId = this.zoneId;
this.form.zoneId = this.zoneId;
console.log(this.queryParams.zoneId)
listSysZoneNav(this.queryParams).then(response => {
this.sysZoneNavList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
navName: null,
parentId: null,
orderNum: null,
url: null,
navType: null,
visible: null,
status: null,
zoneId: this.zoneId,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
rememberOldValue(e,row){
this.oldValue=e.target.value;
},
saveData(e,row) {
let val = e.target.value
if(this.oldValue!=val){
updateSysZoneNav(row).then(response => {
this.$modal.msgSuccess("已保存");
});
}
},
switchChange(row){
updateSysZoneNav(row).then(response => {
this.$modal.msgSuccess("已保存");
});
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getSysZoneNav(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateSysZoneNav(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSysZoneNav(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delSysZoneNav(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('system/sysZoneNav/export', {
// ...this.queryParams
// }, `sysZoneNav_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listPosppChargeView(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['ID','导航名称','父导航ID','显示顺序','访问url','类型(0-初始 1-顶部导航 2-底部导航)','显示状态(0显示 1隐藏)','停用状态(0正常 1停用)','所属站点','创建者','创建时间','更新者','更新时间','备注',];
const filterVal = ['id','navName','parentId','orderNum','url','navType','visible','status','zoneId','createBy','createTime','updateBy','updateTime','remark',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '站点导航链接',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>