From c0244569fbc8b4338aa28b13ecf9d86c0290445b Mon Sep 17 00:00:00 2001 From: clay <20932067@zju.edu.cn> Date: Mon, 10 Jan 2022 23:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=82=E7=BA=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebts-ui/src/api/test/emplee.js | 54 ++++ ebts-ui/src/router/index.js | 13 + ebts-ui/src/utils/hcy.js | 237 ++++++++------- .../views/sist/article/components/article.vue | 189 ++++++------ ebts-ui/src/views/sist/article/index.vue | 16 +- ebts-ui/src/views/sist/articledic/index.vue | 46 +-- ebts-ui/src/views/sist/banner/index.vue | 4 +- ebts-ui/src/views/sist/dire/direData.vue | 285 ++++++++++++++++++ ebts-ui/src/views/sist/dire/index.vue | 24 +- ebts-ui/src/views/utils/uploadFile.vue | 27 +- 10 files changed, 654 insertions(+), 241 deletions(-) create mode 100644 ebts-ui/src/api/test/emplee.js create mode 100644 ebts-ui/src/views/sist/dire/direData.vue diff --git a/ebts-ui/src/api/test/emplee.js b/ebts-ui/src/api/test/emplee.js new file mode 100644 index 0000000..1f87510 --- /dev/null +++ b/ebts-ui/src/api/test/emplee.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + + +// 查询层级结构列表 +export function listEmplee(data) { + return request({ + url: '/test/emplee/list', + method: 'post', + data: data + }) +} + +// 导出层级结构 +export function exportEmplee(data) { + return request({ + url: '/test/emplee/export', + method: 'post', + data: data + }) +} + +// 查询层级结构详细 +export function getEmplee(id) { + return request({ + url: '/test/emplee/' + id, + method: 'get' + }) +} + +// 新增层级结构 +export function addEmplee(data) { + return request({ + url: '/test/emplee', + method: 'post', + data: data + }) +} + +// 修改层级结构 +export function updateEmplee(data) { + return request({ + url: '/test/emplee', + method: 'put', + data: data + }) +} + +// 删除层级结构 +export function delEmplee(id) { + return request({ + url: '/test/emplee/' + id, + method: 'delete' + }) +} \ No newline at end of file diff --git a/ebts-ui/src/router/index.js b/ebts-ui/src/router/index.js index c0eee35..85dde8e 100644 --- a/ebts-ui/src/router/index.js +++ b/ebts-ui/src/router/index.js @@ -105,6 +105,19 @@ export const constantRoutes = [ } ] }, + { + path: '/dire', + component: Layout, + hidden: true, + children: [ + { + path: 'data/:direId/:siteType', + component: (resolve) => require(['@/views/sist/dire/direData'], resolve), + name: 'direData', + meta: { title: '数据配置' } + } + ] + }, { path: '/article', component: Layout, diff --git a/ebts-ui/src/utils/hcy.js b/ebts-ui/src/utils/hcy.js index 7299166..d3616f1 100644 --- a/ebts-ui/src/utils/hcy.js +++ b/ebts-ui/src/utils/hcy.js @@ -7,141 +7,145 @@ const baseURL = process.env.VUE_APP_BASE_API // 日期格式化 export function parseTime(time, pattern) { - if (arguments.length === 0 || !time) { - return null - } - const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' - let date - if (typeof time === 'object') { - date = time - } else { - if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { - time = parseInt(time) - } else if (typeof time === 'string') { - time = time.replace(new RegExp(/-/gm), '/'); - } - if ((typeof time === 'number') && (time.toString().length === 10)) { - time = time * 1000 - } - date = new Date(time) - } - const formatObj = { - y: date.getFullYear(), - m: date.getMonth() + 1, - d: date.getDate(), - h: date.getHours(), - i: date.getMinutes(), - s: date.getSeconds(), - a: date.getDay() - } - const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { - let value = formatObj[key] - // Note: getDay() returns 0 on Sunday - if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } - if (result.length > 0 && value < 10) { - value = '0' + value - } - return value || 0 - }) - return time_str + if (arguments.length === 0 || !time) { + return null + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time.replace(new RegExp(/-/gm), '/'); + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value] + } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str } // 表单重置 export function resetForm(refName) { - if (this.$refs[refName]) { - this.$refs[refName].resetFields(); - } + if (this.$refs[refName]) { + this.$refs[refName].resetFields(); + } } // 添加日期范围 export function addDateRange(params, dateRange) { - var search = params; - search.beginTime = ""; - search.endTime = ""; - if (null != dateRange && '' != dateRange) { - search.beginTime = dateRange[0]; - search.endTime = dateRange[1]; - } - return search; + var search = params; + search.beginTime = ""; + search.endTime = ""; + if (null != dateRange && '' != dateRange) { + search.beginTime = dateRange[0]; + search.endTime = dateRange[1]; + } + return search; } + // 添加搜索创建时间日期范围 export function addCreateDateRange(params, dateRange) { - var search = params; + var search = params; let data = { - beginCreateTime : "", - endCreateTime : "", + beginCreateTime: "", + endCreateTime: "", }; - if (null != dateRange && '' != dateRange) { + if (null != dateRange && '' != dateRange) { data.beginCreateTime = dateRange[0]; data.endCreateTime = dateRange[1]; - } - search.parameter= JSON.stringify(data) + } + search.parameter = JSON.stringify(data) return search; } // 回显数据字典 export function selectDictLabel(datas, value) { - var actions = []; - Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + value)) { - actions.push(datas[key].dictLabel); - return true; - } - }) - return actions.join(''); + var actions = []; + Object.keys(datas).some((key) => { + if (datas[key].dictValue == ('' + value)) { + actions.push(datas[key].dictLabel); + return true; + } + }) + return actions.join(''); } + // 回显数据字典 export function selectDictCode(datas, value) { - var actions = []; - Object.keys(datas).some((key) => { - if (datas[key].dictCode == ('' + value)) { - actions.push(datas[key].dictLabel); - return true; - } - }) - return actions.join(''); + var actions = []; + Object.keys(datas).some((key) => { + if (datas[key].dictCode == ('' + value)) { + actions.push(datas[key].dictLabel); + return true; + } + }) + return actions.join(''); } // 回显数据字典(字符串数组) export function selectDictLabels(datas, value, separator) { - var actions = []; - var currentSeparator = undefined === separator ? "," : separator; - var temp = value.split(currentSeparator); - Object.keys(value.split(currentSeparator)).some((val) => { - Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + temp[val])) { - actions.push(datas[key].dictLabel + currentSeparator); - } - }) - }) - return actions.join('').substring(0, actions.join('').length - 1); + var actions = []; + var currentSeparator = undefined === separator ? "," : separator; + var temp = value.split(currentSeparator); + Object.keys(value.split(currentSeparator)).some((val) => { + Object.keys(datas).some((key) => { + if (datas[key].dictValue == ('' + temp[val])) { + actions.push(datas[key].dictLabel + currentSeparator); + } + }) + }) + return actions.join('').substring(0, actions.join('').length - 1); } // 通用下载方法 export function download(fileName) { - window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; + window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; } // 字符串格式化(%s ) export function sprintf(str) { - var args = arguments, flag = true, i = 1; - str = str.replace(/%s/g, function () { - var arg = args[i++]; - if (typeof arg === 'undefined') { - flag = false; - return ''; - } - return arg; - }); - return flag ? str : ''; + var args = arguments, flag = true, i = 1; + str = str.replace(/%s/g, function () { + var arg = args[i++]; + if (typeof arg === 'undefined') { + flag = false; + return ''; + } + return arg; + }); + return flag ? str : ''; } // 转换字符串,undefined,null等转化为"" export function praseStrEmpty(str) { - if (!str || str == "undefined" || str == "null") { - return ""; - } - return str; + if (!str || str == "undefined" || str == "null") { + return ""; + } + return str; } /** @@ -153,21 +157,28 @@ export function praseStrEmpty(str) { * @param {*} rootId 根Id 默认 0 */ export function handleTree(data, id, parentId, children, rootId) { - id = id || 'id' - parentId = parentId || 'parentId' - children = children || 'children' - rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0 - //对源数据深度克隆 - const cloneData = JSON.parse(JSON.stringify(data)) - //循环所有项 - const treeData = cloneData.filter(father => { - let branchArr = cloneData.filter(child => { - //返回每一项的子级数组 - return father[id] === child[parentId] - }); - branchArr.length > 0 ? father.children = branchArr : ''; - //返回第一层 - return father[parentId] === rootId; - }); - return treeData != '' ? treeData : data; + try { + + id = id || 'id' + parentId = parentId || 'parentId' + children = children || 'children' + rootId = rootId || Math.min.apply(Math, data.map(item => { + return item[parentId] + })) || 0 + //对源数据深度克隆 + const cloneData = JSON.parse(JSON.stringify(data)) + //循环所有项 + const treeData = cloneData.filter(father => { + let branchArr = cloneData.filter(child => { + //返回每一项的子级数组 + return father[id] === child[parentId] + }); + branchArr.length > 0 ? father.children = branchArr : ''; + //返回第一层 + return father[parentId] === rootId; + }); + return treeData != '' ? treeData : data; + } catch (e) { + return null; + } } diff --git a/ebts-ui/src/views/sist/article/components/article.vue b/ebts-ui/src/views/sist/article/components/article.vue index 83416d0..112e8e5 100644 --- a/ebts-ui/src/views/sist/article/components/article.vue +++ b/ebts-ui/src/views/sist/article/components/article.vue @@ -8,26 +8,8 @@ - - - - - - - - - - - - - - - - - - @@ -56,57 +38,70 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + @@ -130,21 +125,25 @@ import Editor from '@/components/Editor'; import {updateArticle, getArticle, drafts, getArticleType, getArticleApprove} from "@/api/sist/article"; import {Message} from "element-ui"; +import UploadFile from '@/views/utils/uploadFile.vue'; export default { components: { Editor, + UploadFile }, props: [], data() { return { submit: 1, + imgurlShow:false, formData: { id: null, title: null, isTop: null, isEnglish: null, content: "", + imgurl:null, }, approveShow: { sist: true, @@ -186,6 +185,11 @@ export default { message: '请选择是否显示', trigger: 'change' }], + imgurl: [{ + required: true, + message: '请选择是否显示', + trigger: 'change' + }], sitetype: [{ required: true, message: '单选框组不能为空', @@ -244,7 +248,6 @@ export default { getArticleType().then(res => { let dictCodes = res.data let articleList = this.articleTypeOptions - console.log(articleList, dictCodes); for (let i = 0; i < articleList.length; i++) { for (let j = 0; j < dictCodes.length; j++) { if (articleList[i].dictCode === dictCodes[j]) { @@ -262,58 +265,76 @@ export default { }, methods: { getSistApprove(dictCode) { + this.judgeThumbnail(dictCode) getArticleApprove(dictCode).then(res => { this.sistApproveOption = res.data }) - }, getLabApprove(dictCode) { + this.judgeThumbnail(dictCode) getArticleApprove(dictCode).then(res => { this.labApproveOption = res.data }) }, + judgeThumbnail(dictCode){ + let articleList = this.articleTypeOptions + for (let article of articleList) { + if (dictCode === article.dictCode && article.attribute1 == 1){ + this.imgurlShow = true + return + } + } + }, submitForm() { + let that_ = this this.$refs['elForm'].validate(valid => { if (valid) { - if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType === null || this.params.labArticleType === "")) { + if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType === null || that_.params.labArticleType === "")) { Message({ message: "请至少选择一个网站发布文章", type: "error", }) - this.msgSuccess("请至少选择一个网站发布文章") return - } else if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType !== null || this.params.labArticleType !== "") && (this.formData.sistApprove === null || this.params.sistApprove === "")) { + } else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType !== null || that_.params.labArticleType !== "") && (that_.formData.sistApprove === null || that_.params.sistApprove === "")) { Message({ message: "请选择信息网站的审批人", type: "error", }) return - } else if ((this.params.sistArticleType === null || this.params.sistArticleType === "") && (this.params.labArticleType != null || this.params.labArticleType !== "") && (this.params.labApprove === null || this.params.labApprove === "")) { + } else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType != null || that_.params.labArticleType !== "") && (that_.params.labApprove === null || that_.params.labApprove === "")) { Message({ message: "请选择实验室网站的审批人", type: "error", }) return } + if (that_.imgurlShow&&(that_.formData.imgurl == ''||that_.formData.imgurl == null)){ + Message({ + message: "请选择缩略图", + type: "error", + }) + return; + } } - this.formData.params = this.params - if (this.submit == 0) { + that_.formData.params = that_.params + if (that_.submit == 0) { Message({ message: "您操作过快", type: "error", }) } else { - this.submit = 0 - this.loading = true; - updateArticle(this.formData).then(response => { - this.loading = false; + that_.submit = 0 + that_.loading = true; + // this.formData.imgurl = this.form.imgurl.url + updateArticle(that_.formData).then(response => { + that_.loading = false; if (response.code == 200) { - this.msgSuccess("提交审批成功"); - this.submit = 1 - this.close(); + that_.msgSuccess("提交审批成功"); + that_.submit = 1 + that_.close(); } }).catch(e => { - this.submit = 1 + that_.submit = 1 }); } // TODO 提交表单 diff --git a/ebts-ui/src/views/sist/article/index.vue b/ebts-ui/src/views/sist/article/index.vue index f606277..8d030a4 100644 --- a/ebts-ui/src/views/sist/article/index.vue +++ b/ebts-ui/src/views/sist/article/index.vue @@ -121,7 +121,11 @@ - + + + @@ -200,7 +204,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ebts-ui/src/views/sist/dire/index.vue b/ebts-ui/src/views/sist/dire/index.vue index 5659d3a..1110195 100644 --- a/ebts-ui/src/views/sist/dire/index.vue +++ b/ebts-ui/src/views/sist/dire/index.vue @@ -1,10 +1,10 @@