lion 2 years ago
parent a53557fec5
commit 62081d00ff

@ -144,7 +144,8 @@ export default {
if(form.hasOwnProperty(key) && $scopedSlots[key]){
formItems.push(
<el-form-item
prop={key}>
prop={key}
class={key}>
{eval(`{$scopedSlots.${key} ? $scopedSlots.${key}() : ''}`)}
</el-form-item>
)

@ -1,7 +1,7 @@
module.exports = {
title: '朗业基础平台',
TOKEN_KEY: 'starter_token',
title: '四世同堂档案管理平台',
TOKEN_KEY: 'ssttDa_token',
/**
* @type {boolean} true | false
* @description Whether fix the header

@ -1,272 +1,375 @@
let base = {
isPhone (val) {
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(val)
},
isDecimal (val) {
return /(^[\-0-9][0-9]*(.[0-9]+)?)$/.test(val)
},
isNumber (val) {
return /(^[\-0-9][0-9]*([0-9]+)?)$/.test(val)
},
isMail (val) {
return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(val)
},
isUrl (url) {
return this.checkUrl(url)
},
checkUrl (url) {
// url= 协议://(ftp的登录信息)[IP|域名](:端口号)(/或?请求参数)
var strRegex =
'^((https|http|ftp)://)?' + // (https或http或ftp):// 可有可无
"(([\\w_!~*'()\\.&=+$%-]+: )?[\\w_!~*'()\\.&=+$%-]+@)?" + // ftp的user@ 可有可无
'(([0-9]{1,3}\\.){3}[0-9]{1,3}' + // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
'|' + // 允许IP和DOMAIN域名
'(localhost)|' + // 匹配localhost
"([\\w_!~*'()-]+\\.)*" + // 域名- 至少一个[英文或数字_!~*\'()-]加上.
'\\w+\\.' + // 一级域名 -英文或数字 加上.
'[a-zA-Z]{1,6})' + // 顶级域名- 1-6位英文
'(:[0-9]{1,5})?' + // 端口- :80 ,1-5位数字
'((/?)|' + // url无参数结尾 - 斜杆或这没有
"(/[\\w_!~*'()\\.;?:@&=+$,%#-]+)+/?)$" // 请求参数结尾- 英文或数字和[]内的各种字符
var re = new RegExp(strRegex, 'i') // i不区分大小写
// 将url做uri转码后再匹配解除请求参数中的中文和空字符影响
if (re.test(encodeURI(url))) {
return true
}
return false
},
matchUrlIp (url, ip) { // url使用是否使用的当前ip
if (!url || !ip) {
return false
}
return url.indexOf(ip.replace('https://', '').replace('http://', '')) >= 0
},
getImgSrc (src, httpUrl) {
if (this.isUrl(src)) {
return src
}
if (httpUrl) {
return httpUrl + src
}
return src
},
previewImg (src, httpUrl) { // 图片预览,目前只支持单图片预览
if (src && !this.isUrl(src) && httpUrl) {
if (src.substr(0, 1) == '/' && httpUrl.substr(httpUrl.length - 1, 1) == '/') {
src = src.substr(1)
}
src = (httpUrl + src)
}
let id = 'vol-preview'
let $div = document.getElementById(id)
if (!$div) {
$div = document.createElement('div')
$div.setAttribute('id', 'vol-preview')
let $mask = document.createElement('div')
$mask.style.position = 'absolute'
$mask.style.width = '100%'
$mask.style.height = '100%'
$mask.style.background = 'black'
$mask.style.opacity = '0.6'
$div.appendChild($mask)
$div.style.position = 'fixed'
$div.style.width = '100%'
$div.style.height = '100%'
// $div.style.overflow = "scroll";
$div.style.top = 0
$div.style['z-index'] = 9999999
let $img = document.createElement('img')
$img.setAttribute('class', 'vol-preview-img')
$img.style.position = 'absolute'
$img.style.top = '50%'
$img.style.left = '50%'
$img.style['max-width'] = '90%'
$img.style['max-height'] = '90%'
$img.style.transform = 'translate(-50%,-50%)'
// $img.src = src;
$img.setAttribute('src', src)
$div.appendChild($img)
$div.addEventListener('click', function () {
this.style.display = 'none'
})
document.body.appendChild($div)
return
}
let $img1 = document.body.appendChild($div).querySelector('.vol-preview-img')
// img.src = src;
$img1.setAttribute('src', src)
$div.style.display = 'block'
},
// 下载文件 $element 标签, url完整url, fileName 文件名, header 以key/value传值
// backGroundUrl 后台url如果后台url直接从后台下载其他全部通过点击a标签下载
dowloadFile (url, fileName, header, backGroundUrl) {
if (!url) return alert('此文件没有url不能下载')
if (!this.isUrl(url)) {
url = backGroundUrl + url
}
window.open(url)
// let $element = document.getElementById('dowonloadfile-a');
// if (!$element) {
// $element = document.createElement('a');
// $element.setAttribute("id", "dowonloadfile-a");
// document.body.append($element);
// }
// //url为一个完整的地址并且不是后台api的地址直接点击a标签下载
// // if (this.isUrl(url) && !this.matchUrlIp(url, backGroundUrl)) {
// // $element.href = url;
// // $element.click();
// // return;
// // }
// if (!this.isUrl(url)) {
// if (!this.isUrl(backGroundUrl + url)) {
// console.log("文件路径不正确");
// alert('文件路径不正确')
// return;
// }
// url = backGroundUrl + url;
// }
// $element.href = url;
// $element.click();
// //通过后台api服务器下载
// if (!this.isUrl(url)) {
// if (!this.isUrl(backGroundUrl + url)) {
// alert('当前下载的文件url【' + url + '】不正确')
// return;
// }
// url = backGroundUrl + url;
// }
// let xmlResquest = new XMLHttpRequest();
// xmlResquest.open("GET", url, true);
// xmlResquest.setRequestHeader("Content-type", "application/json");
// if (header && typeof header == 'object') {
// for (const key in header) {
// xmlResquest.setRequestHeader(
// key,
// header[key]
// );
// }
// }
// xmlResquest.responseType = "blob";
// xmlResquest.onload = function (oEvent) {
// if (xmlResquest.status != 200) {
// return alert('没有下载到此文件的信息')
// }
// let content = xmlResquest.response;
// $element.download = fileName;
// let blob = new Blob([content]);
// $element.href = URL.createObjectURL(blob);
// $element.click();
// };
// xmlResquest.send();
},
downloadImg (data) {
if (!data.url || !data.callback || typeof data.callback !== 'function') {
return
}
// url, backGroundUrl, header, callback
if (this.isUrl(data.url) && !this.matchUrlIp(data.url, data.backGroundUrl)) {
return data.url
}
// 通过后台api服务器下载
if (!this.isUrl(data.url)) {
if (!this.isUrl(data.backGroundUrl + data.url)) {
return
}
data.url = data.backGroundUrl + data.url
}
var xmlResquest = new XMLHttpRequest()
xmlResquest.open('get', data.url, true)
xmlResquest.responseType = 'blob'
xmlResquest.setRequestHeader('Content-Type', 'application/json')
if (data.header && typeof data.header === 'object') {
for (const key in data.header) {
xmlResquest.setRequestHeader(
key,
data.header[key]
)
}
}
xmlResquest.onload = function () {
if (this.status == 200) {
var blob = this.response
callback(window.URL.createObjectURL(blob))
}
}
xmlResquest.send()
},
// 2020.06.01增加通用方法将普通对象转换为tree结构
// data数据格式[
// { name: 'tree1', id: 1, parentId: 0 },
// { name: 'tree2', id: 2, parentId: 0 }]
// 1、id与parentId这两个字段必须有
// 2、树形tree需要注意Id与parentId循环依赖的问题
// 3、callback每次生成一新的节点的时回调的方法
convertTree (data, callback) {
var treeIds = []
var root_data = []
data.forEach(x => {
if (!x.children) {
x.children = []
}
if (!x.hidden && x.id !== undefined && x.id !== x.parentId && !data.some(s => {
return x.parentId == s.id
})) {
x.isRoot = true
callback && callback(x, data, true, treeIds)
root_data.push(x)
getTree(x.id, x, data, callback, treeIds)
}
})
var exceptionNodes = data.filter(f => {
return treeIds.indexOf(f.id) == -1 && !f.hidden
})
root_data.push(...exceptionNodes)
return root_data
},
getTreeAllParent (id, data) { // 获取某个节点的所有父节点信息2020.11.01
var nodes = []
if (!(data instanceof Array)) {
return nodes
}
var _child = data.find(x => { return x.id === id })
if (!_child) {
return []
}
nodes.push(_child)
var _parentIds = [_child.parentId]
for (let index = 0; index < _parentIds.length; index++) {
var _node = data.find(x => { return x.id === _parentIds[index] && x.id !== x.parentId })
if (!_node) {
return nodes
}
_parentIds.push(_node.parentId)
nodes.unshift(_node)
}
return nodes
}
}
export default base
// 2020.06.01增加通用方法将普通对象转换为tree结构
function getTree (id, node, data, callback, treeIds) {
if (treeIds.indexOf(id) == -1) {
treeIds.push(id)
}
data.forEach(x => {
if (!x.hidden && x.parentId == id) {
if (!node.children) node.children = []
callback && callback(x, node, false)
node.children.push(x)
getTree(x.id, x, data, callback, treeIds)
}
})
let base = {
isPhone(val) {
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(val)
},
isDecimal(val) {
return /(^[\-0-9][0-9]*(.[0-9]+)?)$/.test(val)
},
isNumber(val) {
return /(^[\-0-9][0-9]*([0-9]+)?)$/.test(val)
},
isMail(val) {
return /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(val)
},
isUrl(url) {
return this.checkUrl(url)
},
checkUrl(url) {
// url= 协议://(ftp的登录信息)[IP|域名](:端口号)(/或?请求参数)
var strRegex =
'^((https|http|ftp)://)?' + // (https或http或ftp):// 可有可无
"(([\\w_!~*'()\\.&=+$%-]+: )?[\\w_!~*'()\\.&=+$%-]+@)?" + // ftp的user@ 可有可无
'(([0-9]{1,3}\\.){3}[0-9]{1,3}' + // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
'|' + // 允许IP和DOMAIN域名
'(localhost)|' + // 匹配localhost
"([\\w_!~*'()-]+\\.)*" + // 域名- 至少一个[英文或数字_!~*\'()-]加上.
'\\w+\\.' + // 一级域名 -英文或数字 加上.
'[a-zA-Z]{1,6})' + // 顶级域名- 1-6位英文
'(:[0-9]{1,5})?' + // 端口- :80 ,1-5位数字
'((/?)|' + // url无参数结尾 - 斜杆或这没有
"(/[\\w_!~*'()\\.;?:@&=+$,%#-]+)+/?)$" // 请求参数结尾- 英文或数字和[]内的各种字符
var re = new RegExp(strRegex, 'i') // i不区分大小写
// 将url做uri转码后再匹配解除请求参数中的中文和空字符影响
if (re.test(encodeURI(url))) {
return true
}
return false
},
matchUrlIp(url, ip) { // url使用是否使用的当前ip
if (!url || !ip) {
return false
}
return url.indexOf(ip.replace('https://', '').replace('http://', '')) >= 0
},
getImgSrc(src, httpUrl) {
if (this.isUrl(src)) {
return src
}
if (httpUrl) {
return httpUrl + src
}
return src
},
previewImg(src, httpUrl) { // 图片预览,目前只支持单图片预览
if (src && !this.isUrl(src) && httpUrl) {
if (src.substr(0, 1) == '/' && httpUrl.substr(httpUrl.length - 1, 1) == '/') {
src = src.substr(1)
}
src = (httpUrl + src)
}
let id = 'vol-preview'
let $div = document.getElementById(id)
if (!$div) {
$div = document.createElement('div')
$div.setAttribute('id', 'vol-preview')
let $mask = document.createElement('div')
$mask.style.position = 'absolute'
$mask.style.width = '100%'
$mask.style.height = '100%'
$mask.style.background = 'black'
$mask.style.opacity = '0.6'
$div.appendChild($mask)
$div.style.position = 'fixed'
$div.style.width = '100%'
$div.style.height = '100%'
// $div.style.overflow = "scroll";
$div.style.top = 0
$div.style['z-index'] = 9999999
let $img = document.createElement('img')
$img.setAttribute('class', 'vol-preview-img')
$img.style.position = 'absolute'
$img.style.top = '50%'
$img.style.left = '50%'
$img.style['max-width'] = '90%'
$img.style['max-height'] = '90%'
$img.style.transform = 'translate(-50%,-50%)'
// $img.src = src;
$img.setAttribute('src', src)
$div.appendChild($img)
$div.addEventListener('click', function() {
this.style.display = 'none'
})
document.body.appendChild($div)
return
}
let $img1 = document.body.appendChild($div).querySelector('.vol-preview-img')
// img.src = src;
$img1.setAttribute('src', src)
$div.style.display = 'block'
},
// 下载文件 $element 标签, url完整url, fileName 文件名, header 以key/value传值
// backGroundUrl 后台url如果后台url直接从后台下载其他全部通过点击a标签下载
dowloadFile(url, fileName, header, backGroundUrl) {
if (!url) return alert('此文件没有url不能下载')
if (!this.isUrl(url)) {
url = backGroundUrl + url
}
window.open(url)
// let $element = document.getElementById('dowonloadfile-a');
// if (!$element) {
// $element = document.createElement('a');
// $element.setAttribute("id", "dowonloadfile-a");
// document.body.append($element);
// }
// //url为一个完整的地址并且不是后台api的地址直接点击a标签下载
// // if (this.isUrl(url) && !this.matchUrlIp(url, backGroundUrl)) {
// // $element.href = url;
// // $element.click();
// // return;
// // }
// if (!this.isUrl(url)) {
// if (!this.isUrl(backGroundUrl + url)) {
// console.log("文件路径不正确");
// alert('文件路径不正确')
// return;
// }
// url = backGroundUrl + url;
// }
// $element.href = url;
// $element.click();
// //通过后台api服务器下载
// if (!this.isUrl(url)) {
// if (!this.isUrl(backGroundUrl + url)) {
// alert('当前下载的文件url【' + url + '】不正确')
// return;
// }
// url = backGroundUrl + url;
// }
// let xmlResquest = new XMLHttpRequest();
// xmlResquest.open("GET", url, true);
// xmlResquest.setRequestHeader("Content-type", "application/json");
// if (header && typeof header == 'object') {
// for (const key in header) {
// xmlResquest.setRequestHeader(
// key,
// header[key]
// );
// }
// }
// xmlResquest.responseType = "blob";
// xmlResquest.onload = function (oEvent) {
// if (xmlResquest.status != 200) {
// return alert('没有下载到此文件的信息')
// }
// let content = xmlResquest.response;
// $element.download = fileName;
// let blob = new Blob([content]);
// $element.href = URL.createObjectURL(blob);
// $element.click();
// };
// xmlResquest.send();
},
downloadImg(data) {
if (!data.url || !data.callback || typeof data.callback !== 'function') {
return
}
// url, backGroundUrl, header, callback
if (this.isUrl(data.url) && !this.matchUrlIp(data.url, data.backGroundUrl)) {
return data.url
}
// 通过后台api服务器下载
if (!this.isUrl(data.url)) {
if (!this.isUrl(data.backGroundUrl + data.url)) {
return
}
data.url = data.backGroundUrl + data.url
}
var xmlResquest = new XMLHttpRequest()
xmlResquest.open('get', data.url, true)
xmlResquest.responseType = 'blob'
xmlResquest.setRequestHeader('Content-Type', 'application/json')
if (data.header && typeof data.header === 'object') {
for (const key in data.header) {
xmlResquest.setRequestHeader(
key,
data.header[key]
)
}
}
xmlResquest.onload = function() {
if (this.status == 200) {
var blob = this.response
callback(window.URL.createObjectURL(blob))
}
}
xmlResquest.send()
},
// 2020.06.01增加通用方法将普通对象转换为tree结构
// data数据格式[
// { name: 'tree1', id: 1, parentId: 0 },
// { name: 'tree2', id: 2, parentId: 0 }]
// 1、id与parentId这两个字段必须有
// 2、树形tree需要注意Id与parentId循环依赖的问题
// 3、callback每次生成一新的节点的时回调的方法
convertTree(data, callback) {
var treeIds = []
var root_data = []
data.forEach(x => {
if (!x.children) {
x.children = []
}
if (!x.hidden && x.id !== undefined && x.id !== x.parentId && !data.some(s => {
return x.parentId == s.id
})) {
x.isRoot = true
callback && callback(x, data, true, treeIds)
root_data.push(x)
getTree(x.id, x, data, callback, treeIds)
}
})
var exceptionNodes = data.filter(f => {
return treeIds.indexOf(f.id) == -1 && !f.hidden
})
root_data.push(...exceptionNodes)
return root_data
},
getTreeAllParent(id, data) { // 获取某个节点的所有父节点信息2020.11.01
var nodes = []
if (!(data instanceof Array)) {
return nodes
}
var _child = data.find(x => {
return x.id === id
})
if (!_child) {
return []
}
nodes.push(_child)
var _parentIds = [_child.parentId]
for (let index = 0; index < _parentIds.length; index++) {
var _node = data.find(x => {
return x.id === _parentIds[index] && x.id !== x.parentId
})
if (!_node) {
return nodes
}
_parentIds.push(_node.parentId)
nodes.unshift(_node)
}
return nodes
},
//深拷贝数据
deepCopy(data) {
//string,number,bool,null,undefined,symbol
//object,array,date
if (data && typeof data === "object") {
//针对函数的拷贝
if (typeof data === "function") {
let tempFunc = data.bind(null);
tempFunc.prototype = this.deepCopy(data.prototype);
return tempFunc;
}
switch (Object.prototype.toString.call(data)) {
case "[object String]":
return data.toString();
case "[object Number]":
return Number(data.toString());
case "[object Boolean]":
return Boolean(data.toString());
case "[object Date]":
return new Date(data.getTime());
case "[object Array]":
let arr = [];
for (let i = 0; i < data.length; i++) {
arr[i] = this.deepCopy(data[i]);
}
return arr;
//js自带对象或用户自定义类实例
case "[object Object]":
let obj = {};
for (let key in data) {
//会遍历原型链上的属性方法可以用hasOwnProperty来控制 obj.hasOwnProperty(prop)
obj[key] = this.deepCopy(data[key]);
}
return obj;
}
} else {
//string,number,bool,null,undefined,symbol
return data;
}
},
// 按顺序把接口返回值 赋给 form
requestToForm(requestObj, form) {
// 获取a对象中属性的顺序和值
let aKeys = Object.keys(form);
let aValues = aKeys.map(key => form[key]);
// 遍历b对象将属性等于a中属性值的对象深拷贝给a中的相应属性
for (let i = 0; i < aKeys.length; i++) {
let key = aKeys[i];
let value = aValues[i];
if (requestObj[key] === value) {
// 深拷贝对象
Object.assign(form, {
[key]: this.deepCopy(requestObj[key])
});
}
}
// 遍历b对象将b中独有的属性按照a的顺序插入到a中
for (let key in requestObj) {
if (!form[key]) {
// 深拷贝属性值
Object.assign(form, {
[key]: this.deepCopy(requestObj[key])
});
}
}
return form
},
// 根据pid 重组树形结构
buildTree(flatData) {
// 创建一个映射表,用于存储每个 id 对应的数据项
const idMap = {};
flatData.forEach(item => {
idMap[item.id] = item;
});
// 创建根节点集合
const rootNodes = [];
flatData.forEach(item => {
// 如果没有父节点,则将该项添加到根节点集合中
if (parseInt(item.pid) === 0) {
rootNodes.push(item);
} else {
// 否则,将该项添加到父节点的 children 数组中
const parent = idMap[item.pid];
console.log("par",parent)
if (!parent.hasOwnProperty('children')) {
parent.children = [];
}
parent.children.push(item);
}
});
return rootNodes;
}
}
export default base
// 2020.06.01增加通用方法将普通对象转换为tree结构
function getTree(id, node, data, callback, treeIds) {
if (treeIds.indexOf(id) == -1) {
treeIds.push(id)
}
data.forEach(x => {
if (!x.hidden && x.parentId == id) {
if (!node.children) node.children = []
callback && callback(x, node, false)
node.children.push(x)
getTree(x.id, x, data, callback, treeIds)
}
})
}

@ -0,0 +1,140 @@
<template>
<div>
<xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'" :title="type === 'add' ? '新增目录' : '编辑目录'"
:form="form" :rules='rules' @submit="submit">
<template v-slot:pName>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>上级目录
</div>
<div class="xy-table-item-content">
<el-input v-model="form.pName" disabled clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>目录名称
</div>
<div class="xy-table-item-content">
<el-input v-model="form.name" placeholder="请输入目录名称" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:sort>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>排序
</div>
<div class="xy-table-item-content">
<el-input v-model="form.sort" placeholder="请输入排序" type="number" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show
} from "@/api/system/baseForm.js"
import {
deepCopy,
isNull
} from "@/utils";
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
id: '',
table_name: 'catalogs',
form: {
pName: '根目录',
name: '',
sort: 0,
pid: 0,
},
rules: {
name: [{
required: true,
message: '请输入目录名称'
}]
}
}
},
created() {},
methods: {
//
setPid(pid, pName) {
this.form.pid = pid?pid:0
this.form.pName = pName?pName:'根目录'
},
submit() {
if (this.id) {
this.form.id = this.id
}
if (this.type == 'add' || this.type == "child") {
this.form.id = ''
}
console.log("this.form", this.form)
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: this.type === 'add' ? '新增成功' : '编辑成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
table_name: this.table_name,
}).then(res => {
this.form = this.base.requestToForm(res,this.form)
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
} else if (this.type === 'add') {
this.form.pid = 0
this.form.pName = '根目录'
}
} else {
this.id = ''
this.type = "add"
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .pName,
::v-deep .name,
::v-deep .sort,
{
flex-basis: 100%;
}
::v-deep .xy-table-item-content{
width: calc(100% - 140px);
}
</style>

@ -0,0 +1,139 @@
<template>
<div>
<div>
<div ref="lxHeader">
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content">
<div class="searchwrap" style="display: flex;align-items: center;">
<div>
<el-input v-model="select.name" placeholder="请输入目录名称"></el-input>
</div>
<div>
<el-button type="primary" size="small" @click="select.page=1,getList()"></el-button>
</div>
<div>
<el-button type="primary" size="small" @click="editCatalog('add')"></el-button>
</div>
</div>
</div>
</lx-header>
</div>
</div>
<div>
<xy-table :list="list" :isPage="false" rowKey="id"
:table-item="table_item">
<template v-slot:btns>
<el-table-column align='center' label="操作" width="240" header-align="center">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="editCatalog('child',scope.row.id,scope.row.name)"></el-button>
<el-button type="primary" size="small" @click="editCatalog('editor',scope.row.id)"></el-button>
<el-popconfirm style="margin:0 10px" @confirm="deleteList(scope.row.id)" title="确定删除吗?">
<el-button type="danger" size="small" slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</template>
</xy-table>
</div>
<add-catalog ref="addCatalog" @refresh="getList"></add-catalog>
</div>
</template>
<script>
import addCatalog from './components/addCatalog.vue';
import {
index,
destroy
} from "@/api/system/baseForm.js"
export default {
components: {
addCatalog
},
data() {
return {
select: {
name: '',
table_name: 'catalogs',
page: 1,
page_size: 999,
},
list: [],
table_item: [{
prop: 'name',
label: '目录名称',
align: 'left',
}]
}
},
created() {
this.getList()
},
methods: {
editCatalog(type, id,pName) {
if (type == 'editor') {
this.$refs.addCatalog.id = id
}
if(type=='child'){
this.$refs.addCatalog.setPid(id,pName)
}
this.$refs.addCatalog.type = type
this.$refs.addCatalog.isShow = true
},
async getList() {
const res = await index({
page_size: this.select.page_size,
page: this.select.page,
sort_type:'ASC',
sort_name:'sort',
table_name: this.select.table_name,
filter: [{
"key": "name",
"op": "like",
"value": this.select.name
}],
})
if(res.data.length>0){
this.list = this.base.buildTree(res.data)
}
},
deleteList(id) {
var that = this;
destroy({
id: id,
table_name: this.select.table_name
}).then(response => {
this.$Message.success('操作成功');
this.getList()
}).catch(error => {
console.log(error)
reject(error)
})
},
}
}
</script>
<style lang="scss" scoped>
.searchwrap {
display: flex;
align-items: center;
&>div {
display: flex;
align-items: center;
margin-right: 10px;
span {
min-width: 70px;
}
}
}
</style>

@ -0,0 +1,178 @@
<template>
<div>
<xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'"
:title="type === 'add' ? '新增组织' : '编辑组织'" :form="form" :rules='rules' @submit="submit">
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>组织名称
</div>
<div class="xy-table-item-content">
<el-input v-model="form.name" placeholder="请输入目录名称" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:originize_type_id>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>组织类型
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" v-model="form.originize_type_id" @change="changeTypes" placeholder="请选择">
<el-option
v-for="item in list_types"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:sort>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>排序
</div>
<div class="xy-table-item-content">
<el-input v-model="form.sort" placeholder="请输入排序" type="number" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:description>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>组织简介
</div>
<div class="xy-table-item-content">
<el-input v-model="form.description" type="textarea" placeholder="请输入组织简介" clearable
style="width: 100%;"></el-input>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show,
index
} from "@/api/system/baseForm.js"
import {
deepCopy,
isNull
} from "@/utils";
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
id: '',
table_name: 'organizes',
list_types:[],
form: {
name: '',
originize_type_id:"",
sort: 0,
description: '',
originize_type_name:''
},
rules: {
name: [{
required: true,
message: '请输入组织名称'
}],
originize_type_id: [{
required: true,
message: '请选择组织类型'
}]
}
}
},
created() {
this.getTypeList()
},
methods: {
submit() {
if (this.id) {
this.form.id = this.id
}
if (this.type == 'add') {
this.form.id = ''
}
console.log("this.form", this.form)
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: this.type === 'add' ? '新增成功' : '编辑成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
table_name: this.table_name,
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
this.form.originize_type_id =res.originize_type_id?parseInt(res.originize_type_id):''
})
},
changeTypes(e){
if(e){
this.list_types.map(item=>{
if(item.id==e){
this.form.originize_type_name = item.name
this.form.originize_type_id = item.id
}
})
}
},
async getTypeList() {
const res = await index({
page_size: 999,
page: 1,
table_name:'organize_types' ,
})
this.list_types = res.data
},
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
}
} else {
this.id = ''
this.type = "add"
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .description,
::v-deep .name,
::v-deep .sort,
::v-deep .originize_type_id{
flex-basis: 100%;
}
::v-deep .xy-table-item-content{
width: calc(100% - 140px);
}
</style>

@ -0,0 +1,131 @@
<template>
<div>
<xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'"
:title="type === 'add' ? '新增组织类型' : '编辑组织类型'" :form="form" :rules='rules' @submit="submit">
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>类型名称
</div>
<div class="xy-table-item-content">
<el-input v-model="form.name" placeholder="请输入类型名称" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:sort>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>排序
</div>
<div class="xy-table-item-content">
<el-input v-model="form.sort" placeholder="请输入排序" type="number" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:description>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>类型描述
</div>
<div class="xy-table-item-content">
<el-input v-model="form.description" type="textarea" placeholder="请输入类型描述" clearable
style="width: 100%;"></el-input>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show
} from "@/api/system/baseForm.js"
import {
deepCopy,
isNull
} from "@/utils";
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
id: '',
table_name: 'organize_types',
form: {
name: '',
sort: 0,
description: ''
},
rules: {
name: [{
required: true,
message: '请输入类型名称'
}]
}
}
},
created() {},
methods: {
submit() {
if (this.id) {
this.form.id = this.id
}
if (this.type == 'add') {
this.form.id = ''
}
console.log("this.form", this.form)
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: this.type === 'add' ? '新增成功' : '编辑成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
table_name: this.table_name,
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
}
} else {
this.id = ''
this.type = "add"
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .description,
::v-deep .name,
::v-deep .sort{
flex-basis: 100%;
}
::v-deep .xy-table-item-content{
width: calc(100% - 140px);
}
</style>

@ -0,0 +1,142 @@
<template>
<div>
<xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'" :title="'目录授权'" :form="form"
:rules='rules' @submit="submit">
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>组织类型
</div>
<div class="xy-table-item-content">
{{form.name}}
</div>
</div>
</template>
<template v-slot:catalog_ids>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>授权目录
</div>
<div class="xy-table-item-content">
<el-tree v-if="isShow" @check="getSelectedNodes" :data="catalogList" show-checkbox default-expand-all node-key="id"
ref="tree" highlight-current :props="defaultProps">
</el-tree>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show,
index
} from "@/api/system/baseForm.js"
import {
deepCopy,
isNull
} from "@/utils";
export default {
components: {
},
data() {
return {
isShow: false,
id: '',
catalogList: [],
defaultProps: {
children: 'children',
label: 'name'
},
table_name: 'organize_types',
form: {
name: '',
catalog_ids: []
},
rules: {}
}
},
created() {
this.getCatalogList()
},
methods: {
async getCatalogList() {
const res = await index({
page_size: 999,
page: 1,
sort_type: 'ASC',
sort_name: 'sort',
table_name: 'catalogs',
})
if (res.data.length > 0) {
this.catalogList = this.base.buildTree(res.data)
}
},
getSelectedNodes() {
const selectedItems = this.$refs.tree.getCheckedKeys()
this.form.catalog_ids = selectedItems
console.log("selectedItems", selectedItems)
},
submit() {
console.log("this.form", this.form)
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: '授权成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
table_name: this.table_name,
}).then(res => {
this.form = this.base.deepCopy(res)
// this.$refs.tree.setCurrentKey(this.res.catalog_ids);
if(res.catalog_ids){
this.$refs.tree.setCheckedKeys(res.catalog_ids,false)
}
// setCurrentKey
console.log("this.form", this.form)
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
this.getDetail()
} else {
this.id = ''
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .description,
::v-deep .name,
::v-deep .catalog_ids {
flex-basis: 100%;
}
::v-deep .catalog_ids .xy-table-item {
align-items: flex-start;
}
::v-deep .xy-table-item-content {
width: calc(100% - 140px);
}
</style>

@ -0,0 +1,147 @@
<template>
<div>
<div>
<div ref="lxHeader">
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content">
<div class="searchwrap" style="display: flex;align-items: center;">
<div>
<el-input v-model="select.name" placeholder="请输入名称"></el-input>
</div>
<div>
<el-button type="primary" size="small" @click="select.page=1,getList()"></el-button>
</div>
<div>
<el-button type="primary" size="small" @click="editIndex('add')"></el-button>
</div>
</div>
</div>
</lx-header>
</div>
</div>
<div>
<xy-table :list="list" :total="total" @pageIndexChange="pageIndexChange" @pageSizeChange="pageSizeChange"
:table-item="table_item">
<template v-slot:btns>
<el-table-column align='center' label="操作" width="240" header-align="center">
<template slot-scope="scope">
<!-- <el-button type="primary" size="small" @click="editIndex('child',scope.row.id,scope.row.name)"></el-button> -->
<el-button type="primary" size="small" @click="editIndex('editor',scope.row.id)"></el-button>
<el-popconfirm style="margin:0 10px" @confirm="deleteList(scope.row.id)" title="确定删除吗?">
<el-button type="danger" size="small" slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</template>
</xy-table>
</div>
<add-index ref="addIndex" @refresh="getList"></add-index>
</div>
</template>
<script>
import addIndex from './components/addIndex.vue';
import {
index,
destroy
} from "@/api/system/baseForm.js"
export default {
components: {
addIndex
},
data() {
return {
select: {
name: '',
table_name: 'organizes',
page: 1,
page_size: 10,
},
total:0,
list: [],
table_item: [{
type:'index',
width:50
},{
prop: 'name',
label: '组织名称',
align: 'left',
},{
prop: 'originize_type_name',
label: '组织类型',
align: 'left',
}]
}
},
created() {
this.getList()
},
methods: {
editIndex(type, id,pName) {
if (type == 'editor') {
this.$refs.addIndex.id = id
}
this.$refs.addIndex.type = type
this.$refs.addIndex.isShow = true
},
pageIndexChange(e) {
this.select.page = e
this.getList()
},
pageSizeChange(e) {
this.select.page_size = e
this.select.page = 1
this.getList()
},
async getList() {
const res = await index({
page_size: this.select.page_size,
page: this.select.page,
table_name: this.select.table_name,
filter: [{
"key": "name",
"op": "like",
"value": this.select.name
}],
})
this.list = res.data
this.total = res.total
},
deleteList(id) {
var that = this;
destroy({
id: id,
table_name: this.select.table_name
}).then(response => {
this.$Message.success('操作成功');
this.getList()
}).catch(error => {
console.log(error)
reject(error)
})
},
}
}
</script>
<style lang="scss" scoped>
.searchwrap {
display: flex;
align-items: center;
&>div {
display: flex;
align-items: center;
margin-right: 10px;
span {
min-width: 70px;
}
}
}
</style>

@ -0,0 +1,155 @@
<template>
<div>
<div>
<div ref="lxHeader">
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content">
<div class="searchwrap" style="display: flex;align-items: center;">
<div>
<el-input v-model="select.name" placeholder="请输入名称"></el-input>
</div>
<div>
<el-button type="primary" size="small" @click="select.page=1,getList()"></el-button>
</div>
<div>
<el-button type="primary" size="small" @click="editType('add')"></el-button>
</div>
</div>
</div>
</lx-header>
</div>
</div>
<div>
<xy-table :list="list" :total="total" @pageIndexChange="pageIndexChange" @pageSizeChange="pageSizeChange"
:table-item="table_item">
<template v-slot:btns>
<el-table-column align='center' label="操作" width="280" header-align="center">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="editCatalog(scope.row.id)"></el-button>
<el-button type="primary" size="small" @click="editType('editor',scope.row.id)"></el-button>
<el-popconfirm style="margin:0 10px" @confirm="deleteList(scope.row.id)" title="确定删除吗?">
<el-button type="danger" size="small" slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</template>
</xy-table>
</div>
<add-type ref="addType" @refresh="getList"></add-type>
<bind-catalog ref="bindCatalog" @refresh="getList"></bind-catalog>
</div>
</template>
<script>
import addType from './components/addType.vue';
import bindCatalog from './components/bindCatalog.vue';
import {
index,
destroy
} from "@/api/system/baseForm.js"
export default {
components: {
addType,
bindCatalog
},
data() {
return {
select: {
name: '',
table_name: 'organize_types',
page: 1,
page_size: 10,
},
total: 0,
list: [],
table_item: [{
type: 'index',
width: 50
}, {
prop: 'name',
label: '组织类型名称',
align: 'left',
width: 240
}, {
prop: 'description',
label: '描述',
align: 'left'
}]
}
},
created() {
this.getList()
},
methods: {
editType(type, id, pName) {
if (type == 'editor') {
this.$refs.addType.id = id
}
this.$refs.addType.type = type
this.$refs.addType.isShow = true
},
editCatalog(id) {
this.$refs.bindCatalog.id = id
this.$refs.bindCatalog.isShow = true
},
pageIndexChange(e) {
this.select.page = e
this.getList()
},
pageSizeChange(e) {
this.select.page_size = e
this.select.page = 1
this.getList()
},
async getList() {
const res = await index({
page_size: this.select.page_size,
page: this.select.page,
table_name: this.select.table_name,
filter: [{
"key": "name",
"op": "like",
"value": this.select.name
}],
})
this.list = res.data
this.total = res.total
},
deleteList(id) {
var that = this;
destroy({
id: id,
table_name: this.select.table_name
}).then(response => {
this.$Message.success('操作成功');
this.getList()
}).catch(error => {
console.log(error)
reject(error)
})
},
}
}
</script>
<style lang="scss" scoped>
.searchwrap {
display: flex;
align-items: center;
&>div {
display: flex;
align-items: center;
margin-right: 10px;
span {
min-width: 70px;
}
}
}
</style>
Loading…
Cancel
Save