修改插件
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
yiqiu
2025-11-21 00:01:45 +08:00
parent 7bc68457e9
commit cbd6250967
224 changed files with 61713 additions and 18 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
(function () {
document.documentElement.setAttribute('theme-mode', localStorage.getItem('theme-mode') || 'light')
document.documentElement.setAttribute('theme-color', localStorage.getItem('theme-color') || 'default')
if (localStorage.getItem('lang') == null) {
document.writeln('<script src="./lang/zh-cn.js"><\/script>')
} else {
document.writeln('<script src="./lang/' + localStorage.getItem('lang') + '.js"><\/script>')
}
}())

View File

@@ -0,0 +1,181 @@
(function (window, undefined) {
var old_onload = window.onload;
window.onload = function () {
const aside = document.getElementById('aside')
const footer = document.getElementById('footer')
Vue.prototype.lang = window.lang
if (!localStorage.getItem('jwt')) {
location.href = 'login.html'
}
const MODE_OPTIONS = [
{ type: 'light', text: window.lang.theme_light, src: './img/assets-setting-light.svg' },
{ type: 'dark', text: window.lang.theme_dark, src: './img/assets-setting-dark.svg' }
]
const COLOR_OPTIONS = ['default', 'cyan', 'green', 'yellow', 'orange', 'red', 'pink', 'purple']
/* aside */
aside && new Vue({
data: {
collapsed: false,
isSearchFocus: false,
searchData: '',
/* 系统设置 */
visible: false,
formData: {
mode: localStorage.getItem('theme-mode') || 'light',
brandTheme: localStorage.getItem('theme-color') || 'default'
},
MODE_OPTIONS,
COLOR_OPTIONS,
colorList: {
DEFAULT: {
'@brand-color': '#0052D9'
},
CYAN: {
'@brand-color': '#0594FA'
},
GREEN: {
'@brand-color': '#00A870'
},
ORANGE: {
'@brand-color': '#ED7B2F'
},
RED: {
'@brand-color': '#E34D59'
},
PINK: {
'@brand-color': '#ED49B4'
},
PURPLE: {
'@brand-color': '#834EC2'
},
YELLOW: {
'@brand-color': '#EBB105'
},
},
curSrc: localStorage.getItem('country_imgUrl') || './img/CN.png',
langList: [],
expanded: [],
curValue: Number(localStorage.getItem('curValue')) || 2,
iconList: ['user', 'view-module', 'cart', 'setting', 'folder-open', 'precise-monitor'],
navList: [],
},
mounted () {
const auth = JSON.parse(localStorage.getItem('auth'))
this.navList = this.getAuth(auth)
this.navList.forEach(item => {
item.child.forEach(el => {
if (el.id === this.curValue) {
this.expanded = []
this.expanded.push(item.id)
}
})
})
this.langList = JSON.parse(localStorage.getItem('common_set')).lang_admin
},
methods: {
getAuth (auth) {
return auth.map(item => {
item.child = item.child.filter(el => el.url)
return item
})
},
jumpHandler (e) {
localStorage.setItem('curValue', e.id)
location.href = e.url || (e.child && e.child[0].url)
},
changeCollapsed () {
this.collapsed = !this.collapsed
},
changeSearchFocus (value) {
if (!value) {
this.searchData = '';
}
this.isSearchFocus = value;
},
// 个人中心
handleNav () {
},
// 退出登录
async handleLogout () {
try {
const res = await Axios.post('/logout')
this.$message.success(res.data.msg)
setTimeout(() => {
location.href = 'login.html'
}, 300)
} catch (error) {
this.$message.error(error.data.msg)
}
},
// 语言切换
changeLang (e) {
console.log(e)
const index = this.langList.findIndex(item => item.file_name === e.value)
if (localStorage.getItem('lang') !== e.value || !localStorage.getItem('lang')) {
if (localStorage.getItem('lang')) {
window.location.reload()
}
localStorage.setItem('country_imgUrl', this.langList[index].country_imgUrl)
localStorage.setItem('lang', e.value)
}
},
// 颜色配置
toUnderline (name) {
return name.replace(/([A-Z])/g, '_$1').toUpperCase();
},
getBrandColor (type, colorList) {
const name = /^#[A-F\d]{6}$/i.test(type) ? type : this.toUnderline(type);
return colorList[name || 'DEFAULT'];
},
/* 页面配置 */
toggleSettingPanel () {
this.visible = true
},
handleClick () {
this.visible = true
},
getModeIcon (mode) {
if (mode === 'light') {
return SettingLightIcon
}
if (mode === 'dark') {
return SettingDarkIcon
}
return SettingAutoIcon
},
// 主题
onPopupVisibleChange (visible, context) {
if (!visible && context.trigger === 'document') this.isColoPickerDisplay = visible
},
},
watch: {
'formData.mode' () {
if (this.formData.mode === 'auto') {
document.documentElement.setAttribute('theme-mode', '')
} else {
document.documentElement.setAttribute('theme-mode', this.formData.mode)
}
localStorage.setItem('theme-mode', this.formData.mode)
},
'formData.brandTheme' () {
document.documentElement.setAttribute('theme-color', this.formData.brandTheme);
localStorage.setItem('theme-color', this.formData.brandTheme)
}
}
}).$mount(aside)
/* footer */
footer && new Vue({
data () {
return {}
}
}).$mount(footer)
var loading = document.getElementById('loading')
setTimeout(() => {
loading && (loading.style.display = 'none')
}, 200)
typeof old_onload == 'function' && old_onload()
};
})(window);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
(function () {
if (localStorage.getItem('backLang') == null) {
document.writeln('<script src="/plugins/addon/idcsmart_ticket/template/admin/lang/zh-cn.js"><\/script>')
} else {
document.writeln('<script src="/plugins/addon/idcsmart_ticket/template/admin/lang/' + localStorage.getItem('backLang') + '.js"><\/script>')
}
}())

View File

@@ -0,0 +1,195 @@
(function (window, undefined) {
var old_onload = window.onload;
window.onload = function () {
const template = document.getElementsByClassName("template")[0];
Vue.prototype.lang = Object.assign(window.lang, window.plugin_lang);
const host = location.origin;
const fir = location.pathname.split("/")[1];
const str = `${host}/${fir}/`;
new Vue({
components: {
comConfig,
comTinymce,
comChooseUser,
},
data() {
return {
isSubmitIng: false,
detialform: {
host_ids: [],
ticket_type_id: "",
},
userParams: {
keywords: "",
page: 1,
limit: 20,
orderby: "id",
sort: "desc",
},
userTotal: 0,
searchLoading: false,
departmentList: [],
orderTypeOptions: [],
// 关联客户下拉框数据
clientOptions: [],
// 关联产品下拉框数据
hostOptions: [],
popupProps: {
overlayInnerStyle: (trigger) => ({
width: `${trigger.offsetWidth}px`,
"max-height": "362px",
}),
},
requiredRules: {
title: [{ required: true, message: lang.order_text15 }],
ticket_type_id: [{ required: true, message: lang.order_name }],
client_id: [{ required: true, message: lang.order_text17 }],
},
batchFile: [],
uploadUrl: str + "v1/upload",
uploadHeaders: {
Authorization: "Bearer" + " " + localStorage.getItem("backJwt"),
},
};
},
methods: {
formatResponse(res) {
if (res.status !== 200) {
this.$nextTick(() => {
this.batchFile = [];
});
this.batchFile = [];
return { error: res.msg };
}
return { save_name: res.data.save_name, url: res.data.image_url };
},
filterMethod() {
return true;
},
changeUser(val) {
// 选择用户, 获取对应的产品
this.$set(this.detialform, "client_id", val);
this.clientChange(val);
},
departmentChange(val) {
this.getOrderTypeOptions(val);
this.detialform.ticket_type_id = "";
},
addOrderFormSubmit() {
this.detialform.content = this.$refs.comTinymce.getContent();
// this.detialform.notes = tinyMCE.editors[1].getContent();
this.$refs.myform.validate(this.requiredRules).then((res) => {
if (res !== true) {
const firstError = Object.values(res)[0][0].message;
this.$message.warning({
content: firstError,
placement: "top-right",
});
return;
}
this.isSubmitIng = true;
const data = this.detialform;
const attachmentList = (this.batchFile || []).map(
(item) => item.response.save_name
);
const params = {
title: data.title, //工单标题
ticket_type_id: data.ticket_type_id, //工单类型ID
client_id: data.client_id ? data.client_id : null, //关联用户
host_ids: data.host_ids ? data.host_ids : [], //关联产品ID,数组
content: data.content ? data.content : "", //问题描述
notes: data.notes ? data.notes : "",
attachment: attachmentList, //附件,数组,取上传文件返回值save_name)
};
newUserOrder(params)
.then((result) => {
this.isSubmitIng = false;
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.goList();
})
.catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
this.isSubmitIng = false;
});
});
},
// 获取工单类型数据
getOrderTypeOptions(id) {
const params = {
admin_role_id: id ? id : "",
};
getUserOrderType(params)
.then((result) => {
this.orderTypeOptions = result.data.data.list;
})
.catch();
},
// 获取用户列表
async getClientOptions() {
try {
const {
data: { data },
} = await getClient(this.userParams);
this.userTotal = data.count;
if (this.userParams.page === 1) {
this.clientOptions = data.list;
} else {
this.clientOptions = this.clientOptions.concat(...data.list);
}
this.searchLoading = false;
} catch (error) {
this.searchLoading = false;
}
},
// 工单-转内部-关联用户变化
clientChange(val) {
// 清除已选产品数据
this.detialform.host_ids = [];
getHost({ client_id: val, page: 1, limit: 10000 }).then((result) => {
this.hostOptions = result.data.data.list
.filter((item) => item.status !== "Deleted")
.map((item) => {
const flagString = item.dedicate_ip
? item.dedicate_ip
: item.name
? item.name
: "";
item.showName = flagString
? `${item.product_name}(${flagString})`
: item.product_name;
return item;
});
this.hostChange();
});
},
// 工单-转内部-关联产品变化
hostChange() {
this.$forceUpdate();
},
// 获取工单部门
getTicketDepartment() {
ticketDepartment().then((res) => {
this.departmentList = res.data.data.list;
});
},
// 返回
goList() {
location.href = "index.htm";
},
},
created() {
this.getOrderTypeOptions();
this.getClientOptions();
this.getTicketDepartment();
},
}).$mount(template);
typeof old_onload == "function" && old_onload();
};
})(window);

View File

@@ -0,0 +1,832 @@
(function (window, undefined) {
var old_onload = window.onload;
window.onload = function () {
const template = document.getElementsByClassName("template")[0];
Vue.prototype.lang = Object.assign(window.lang, window.plugin_lang);
const host = location.origin;
const fir = location.pathname.split("/")[1];
const str = `${host}/${fir}/`;
new Vue({
components: {
comConfig,
comTinymce,
},
data() {
return {
// 加载中
pageLoading: false,
// 删除对话框
deleteVisible: false,
replayVisible: false,
sendLoading: false,
isAddNotes: false,
viewer: null,
deliveryVisible: false,
// 添加备注按钮的loading
addNotesLing: false,
top: "top",
currency_prefix:
JSON.parse(localStorage.getItem("common_set")).currency_prefix ||
"¥",
currency_suffix:
JSON.parse(localStorage.getItem("common_set")).currency_suffix ||
"元",
// 工单详情
isEditing: false, // 是否正在编辑模式
orderDetailData: {},
delivery_operate_type: {
1: lang.order_text81,
2: lang.order_text82,
3: lang.order_text83,
},
deliveryLoading: false,
params: {
selectHostList: [], // 选择的产品
listStr: "",
ticket_type: "", // 产品类型
status: "", // 工单状态
},
// 回复内容
replyData: "",
editObj: {}, // 正在编辑的对象
// 产品列表
hostList: [],
// 编辑按钮loading
editLoding: false,
// 订单类型列表
order_status_options: [],
// 回复列表
replyList: [],
product_obj_list: [],
prereplyList: [],
// 日志列表
logList: [],
logVisible: false,
columns: [
{
colKey: "description",
title: lang.order_text39,
cell: "description",
ellipsis: true,
},
{
colKey: "create_time",
title: lang.order_text40,
cell: "create_time",
width: "157",
},
],
// 工单状态下拉框数据
orderTypeList: [],
// 上传附件
attachmentList: [],
// 预览图片地址
preImg: "",
// 上传附件headers设置
uploadHeaders: {
Authorization: "Bearer" + " " + localStorage.getItem("backJwt"),
},
uploadTip: "",
img_visible: false,
baseURL: url,
uploadUrl: str + "v1/upload",
/** 非受控用法:与分页组件对齐(此处注释为非受控用法示例,代码有效,勿删) */
pagination: {
current: 1,
pageSize: 10,
total: 0,
showJumper: true,
},
};
},
computed: {
avatar() {
return (type) => {
return type === "Client"
? `${this.baseURL}img/client.png`
: `${this.baseURL}img/admin.png`;
};
},
},
methods: {
formatResponse(res) {
if (res.status !== 200) {
this.$message.error(res.msg);
return {error: res.msg};
}
return {save_name: res.data.save_name, url: res.data.image_url};
},
// 分页变化时触发该事件
onPageChange(pageInfo, newData) {
// 受控用法所需
this.pagination.current = pageInfo.current;
this.pagination.pageSize = pageInfo.pageSize;
},
// 点击预设回复弹窗
usePrePlay(item) {
tinyMCE.editors[0].setContent(item.content);
this.replayVisible = false;
},
// 点击图片
hanldeImage(event) {
if (
event.target.nodeName == "IMG" ||
event.target.nodeName == "img"
) {
const img = event.target.currentSrc;
this.preImg = img;
this.viewer.show();
}
},
// 跳转用户信息页
goUserPagr() {
const url =
str +
`client_detail.htm?client_id=${this.orderDetailData.client_id}`;
window.open(url);
},
goClientPage(id) {
if (id) {
const url = str + `client_detail.htm?client_id=${id}`;
window.open(url);
}
},
// 获取工单预设回复列表
getTicketPrereply() {
ticketPrereply()
.then((res) => {
this.prereplyList = res.data.data.list;
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
goList() {
window.history.go(-1);
},
goProductDetail(item) {
const url =
str + `host_detail.htm?client_id=${item.client_id}&id=${item.id}`;
window.open(url);
},
// 确认添加备注
handelAddNotes() {
this.addNotesLing = true;
const content = tinyMCE.editors[0].getContent();
const params = {
id: this.orderDetailData.id,
content: content,
};
addTicketNotes(params)
.then((res) => {
this.getOrderDetailData();
tinyMCE.editors[0].setContent("");
this.isAddNotes = false;
})
.catch((error) => {
this.$message.warning({
content: error.data.msg,
placement: "top-right",
});
})
.finally(() => {
this.addNotesLing = false;
});
},
// 取消添加备注
cancelAddNotes() {
tinyMCE.editors[0].setContent("");
this.isAddNotes = false;
},
// 备注列表
getTicketNotes() {
const str = location.search.substr(1).split("&");
const orderId = str[0].split("=")[1];
ticketNotes(orderId)
.then((res) => {
this.notesList = res.data.data.list;
const arr = this.orderDetailData.replies.concat(this.notesList);
arr.sort((a, b) => {
return a.create_time - b.create_time;
});
arr.forEach((item) => {
item.isShowBtn = false;
if (!item.type) {
item.type = "notes";
}
});
const arrEntities = {
lt: "<",
gt: ">",
nbsp: " ",
amp: "&",
quot: '"',
};
this.replyList = arr.map((item) => {
item.content = filterXSS(
item.content.replace(
/&(lt|gt|nbsp|amp|quot);/gi,
function (all, t) {
return arrEntities[t];
}
)
).replace(/&(lt|gt|nbsp|amp|quot);/gi, function (all, t) {
return arrEntities[t];
});
item.content = item.content.replaceAll(
'http-equiv="refresh"',
""
);
return item;
});
})
.catch((err) => {
console.log(err);
this.replyList = this.orderDetailData.replies.concat([]);
this.$message.error(err.data.msg);
})
.finally(() => {
this.pageLoading = false;
this.$nextTick(() => {
this.scrollBotton();
});
});
},
// 编辑消息
editItem(item) {
this.editObj = item;
this.isEditing = true;
this.replyData = item.content;
this.$refs.comTinymce.setContent(item.content);
tinyMCE.editors[0].editorManager.get("tiny").focus();
this.handleScrollBottom();
},
// 聊天列表滚动到底部
scrollBotton() {
const listDom = document.querySelector(".reply-list");
const listBoxDom = document.querySelector(".t-list__inner");
const h = listBoxDom.scrollHeight;
listDom.scrollTop = h;
},
// 滚动到底部
handleScrollBottom() {
const detailDom = document.querySelector(".area");
detailDom.scrollTop = detailDom.scrollHeight;
},
// 确认编辑
handelEdit() {
this.editLoding = true;
const conten = tinyMCE.editors[0].getContent();
if (this.editObj.type === "notes") {
const params = {
ticket_id: this.editObj.ticket_id,
id: this.editObj.id,
content: conten,
};
notesReplyEdit(params)
.then((result) => {
this.getOrderDetailData();
tinyMCE.editors[0].setContent("");
this.isEditing = false;
})
.catch((error) => {
this.$message.warning({
content: error.data.msg,
placement: "top-right",
});
})
.finally(() => {
this.editLoding = false;
});
} else {
const params = {
id: this.editObj.id,
content: conten,
};
ticketReplyEdit(this.editObj.id, params)
.then((result) => {
this.getOrderDetailData();
tinyMCE.editors[0].setContent("");
this.isEditing = false;
})
.catch((error) => {
this.$message.warning({
content: error.data.msg,
placement: "top-right",
});
})
.finally(() => {
this.editLoding = false;
});
}
},
copyIp(row) {
const allIp = (row.dedicate_ip + "," + row.assign_ip).replace(
/,/g,
"\n"
);
copyText(allIp);
},
// 点击添加备注
addNotes() {
this.isAddNotes = true;
tinyMCE.editors[0].editorManager.get("tiny").focus();
},
// 取消编辑
cancelEdit() {
this.editObj = {};
this.replyData = "";
this.$refs.comTinymce.setContent("");
tinyMCE.editors[0].setContent("");
this.isEditing = false;
},
// 点击删除按钮
deleteItem(item) {
if (this.isEditing) {
this.$message.error(lang.order_text41);
return;
}
this.editObj = item;
this.deleteVisible = true;
},
// 删除弹窗确认
handelDelete() {
if (this.editObj.type === "notes") {
const params = {
ticket_id: this.editObj.ticket_id,
id: this.editObj.id,
};
orderNotesDelete(params)
.then((result) => {
this.getOrderDetailData();
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
})
.catch((err) => {
this.$message.error(err.data.msg);
})
.finally(() => {
this.deleteVisible = false;
});
} else {
const params = {
id: this.editObj.id,
};
orderReplyDelete(params)
.then((result) => {
this.getOrderDetailData();
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
})
.catch((err) => {
this.$message.error(err.data.msg);
})
.finally(() => {
this.deleteVisible = false;
});
}
},
handelDeliveryOperate() {
this.deliveryLoading = true;
const subApi =
this.orderDetailData.delivery_operate === 1
? apiDeliveryManual
: this.orderDetailData.delivery_operate === 2
? apiDeliveryActive
: this.orderDetailData.delivery_operate === 3
? apiDeliveryTerminate
: apiDeliveryManual;
subApi({
id: this.orderDetailData.id,
})
.then((res) => {
this.deliveryLoading = false;
this.deliveryVisible = false;
this.$message.success(res.data.msg);
this.getOrderDetailData();
})
.catch((err) => {
this.deliveryLoading = false;
this.$message.error(err.data.msg);
});
},
// 提交回复
submitReply() {
this.sendLoading = true;
const conten = tinyMCE.editors[0].getContent();
const attachmentList = [];
this.attachmentList.forEach((item) => {
attachmentList.push(item.response.save_name);
});
const params = {
id: this.orderDetailData.id,
content: conten,
attachment: attachmentList,
};
replyUserOrder(this.orderDetailData.id, params)
.then((result) => {
tinyMCE.editors[0].setContent("");
this.attachmentList = [];
this.getOrderDetailData();
})
.catch((error) => {
this.$message.warning({
content: error.data.msg,
placement: "top-right",
});
})
.finally(() => {
this.sendLoading = false;
});
},
goback() {
location.href = "index.htm";
},
// 工单-转内部-关联产品变化
hostChange() {
this.$forceUpdate();
},
// 上传附件-返回内容
uploadFormatResponse(res) {
if (!res || res.status !== 200) {
return {error: lang.upload_fail};
}
return {...res, save_name: res.data.save_name};
},
// 修改工单状态
handelEditOrderStatus() {
if (this.params.status == "") {
return this.$message.warning({
content: lang.order_text42,
placement: "top-right",
});
}
const str = location.search.substr(1).split("&");
const orderId = str[0].split("=")[1];
const obj = {
id: orderId,
status: this.params.status,
ticket_type_id: this.params.ticket_type,
host_ids: [this.params.listStr],
};
this.editLoding = true;
editOrderStatus(obj)
.then((result) => {
if (obj.status == 4) {
this.goList();
} else {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getOrderDetailData();
}
this.editLoding = false;
})
.catch((err) => {
this.editLoding = false;
this.$message.error(err.data.msg);
});
},
handelLog() {
this.pagination.current = 1;
this.pagination.pageSize = 10;
this.getTicketLog();
this.logVisible = true;
},
// 上传附件-进度
uploadProgress(val) {
if (val.percent) {
this.uploadTip = "uploaded" + val.percent + "%";
if (val.percent === 100) {
this.uploadTip = "";
}
}
},
// 上传附件-成功后
uploadSuccess(res) {
if (
res.fileList.filter((item) => item.name == res.file.name).length > 1
) {
this.$message.warning({
content: lang.upload_same_name,
placement: "top-right",
});
this.attachmentList.splice(this.attachmentList.length - 1, 1);
}
this.$forceUpdate();
},
// 删除已上传附件
removeAttachment(file, i) {
this.attachmentList.splice(i, 1);
this.$forceUpdate();
},
// 下载文件
downFile(res, title) {
let url = res.lastIndexOf("/");
res = res.substring(url + 1, res.length);
downloadFile({name: res})
.then(function (response) {
const blob = new Blob([response.data]);
const fileName = title;
const linkNode = document.createElement("a");
linkNode.download = fileName; //a标签的download属性规定下载文件的名称
linkNode.style.display = "none";
linkNode.href = URL.createObjectURL(blob); //生成一个Blob URL
document.body.appendChild(linkNode);
linkNode.click(); //模拟在按钮上的一次鼠标单击
URL.revokeObjectURL(linkNode.href); // 释放URL 对象
document.body.removeChild(linkNode);
})
.catch(function (error) {
console.log(error);
this.$message.error(error.data.msg);
});
},
// 附件下载
clickFile(item) {
const name = item.name;
const url = item.url;
const type = name.substring(name.lastIndexOf(".") + 1);
if (
[
"png",
"jpg",
"jpeg",
"bmp",
"webp",
"PNG",
"JPG",
"JPEG",
"BMP",
"WEBP",
].includes(type)
) {
this.preImg = url;
this.viewer.show();
} else {
const downloadElement = document.createElement("a");
downloadElement.href = url;
downloadElement.download = name; // 下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); // 点击下载
}
},
timeago(time) {
if (time == 0) {
return "--";
}
// time 毫秒
const dateTimeStamp = time;
const minute = 1000 * 60; //把分,时,天,周,半个月,一个月用毫秒表示
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = month * 12;
const now = new Date().getTime(); //获取当前时间毫秒
const diffValue = now - dateTimeStamp; //时间差
let result = "";
if (diffValue < 0) {
result = "" + lang.order_text43;
}
const minC = diffValue / minute; //计算时间差的分,时,天,周,月
const hourC = diffValue / hour;
const dayC = diffValue / day;
const weekC = diffValue / week;
const monthC = diffValue / month;
const yearC = diffValue / year;
if (yearC >= 1) {
result = " " + parseInt(yearC) + lang.order_text44;
} else if (monthC >= 1 && monthC < 12) {
result = " " + parseInt(monthC) + lang.order_text45;
} else if (weekC >= 1 && weekC < 5 && dayC > 6 && monthC < 1) {
result = " " + parseInt(weekC) + lang.order_text46;
} else if (dayC >= 1 && dayC <= 6) {
result = " " + parseInt(dayC) + lang.order_text47;
} else if (hourC >= 1 && hourC <= 23) {
result = " " + parseInt(hourC) + lang.order_text48;
} else if (minC >= 1 && minC <= 59) {
result = " " + parseInt(minC) + lang.order_text49;
} else if (diffValue >= 0 && diffValue <= minute) {
result = lang.order_text50;
}
return result;
},
goBotoom() {
// .area 平滑的滑到最底部
const listDom = document.querySelector(".area");
const h = listDom.scrollHeight;
listDom.scrollTo({left: 0, top: h, behavior: "smooth"});
},
// 工单日志
getTicketLog() {
const str = location.search.substr(1).split("&");
const orderId = str[0].split("=")[1];
ticketLog(orderId)
.then((res) => {
this.logList = res.data.data.list;
this.pagination.total = res.data.data.list.length;
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
// 获取工单详情
async getOrderDetailData() {
this.pageLoading = true;
const str = location.search.substr(1).split("&");
const orderId = str[0].split("=")[1];
const result = await getUserOrderDetail(orderId);
if (result.status === 200) {
this.orderDetailData = result.data.data.ticket;
this.orderDetailData.distanceTime = this.timeago(
this.orderDetailData.last_reply_time * 1000
);
this.getOrderTypeName();
this.getHostsName();
this.getTicketStatus();
this.getTicketNotes();
}
},
// 获取当前工单类型名称
getOrderTypeName() {
getUserOrderType()
.then((result) => {
const orderTypeList = result.data.data.list;
this.orderTypeList = orderTypeList;
const orderType = orderTypeList.filter(
(item) => item.id === this.orderDetailData.ticket_type_id
)[0];
this.params.ticket_type = orderType ? orderType.id : null;
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
// 获取当前用户关联产品名称
getHostsName() {
getHost({
client_id: this.orderDetailData.client_id,
page: 1,
limit: 999999999,
})
.then((result) => {
const data = result.data.data.list;
data.forEach((item) => {
item.showName = item.product_name + "(" + item.name + ")";
});
this.hostList = data;
const arr = [];
this.product_obj_list = [];
this.orderDetailData.host_ids.forEach((id) => {
data.forEach((item) => {
if (item.id == id) {
arr.push(item.id);
this.product_obj_list.push(item);
}
});
});
this.params.selectHostList = [...arr];
this.params.listStr = arr[0] || "";
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
// 获取工单状态列表
getTicketStatus() {
ticketStatus()
.then((res) => {
res.data.data.list.forEach((item) => {
// if (item['default'] === 1) {
// this.order_status.push(item.id)
// }
if (item.name === this.orderDetailData.status) {
this.params.status = item.id;
}
delete item["default"];
});
this.order_status_options = res.data.data.list;
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
// 时间格式转换
formatDate(dateStr) {
const date = new Date(dateStr * 1000);
const str1 = [
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
].join("-");
const str2 = [
this.formatDateAdd0(date.getHours()),
this.formatDateAdd0(date.getMinutes()),
].join(":");
return str1 + " " + str2;
},
formatDateAdd0(m) {
return m < 10 ? "0" + m : m;
},
initTemplate() {
tinymce.init({
selector: "#tiny",
language_url: "/tinymce/langs/zh_CN.js",
language:
localStorage.getItem("backLang") === "zh-cn" ? "zh_CN" : "en_US",
min_height: 400,
width: "100%",
plugins:
"link lists image code table colorpicker textcolor wordcount contextmenu fullpage paste",
toolbar:
"bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent blockquote | undo redo | link unlink image fullpage code | removeformat",
images_upload_url: str + "v1/upload",
paste_data_images: true,
convert_urls: false,
//粘贴图片后,自动上传
urlconverter_callback: function (url, node, on_save, name) {
return url;
},
images_upload_handler: this.handlerAddImg,
});
},
handlerAddImg(blobInfo, success, failure) {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append("file", blobInfo.blob());
axios
.post(`${location.protocol}//${str}v1/upload`, formData, {
headers: {
Authorization:
"Bearer" + " " + localStorage.getItem("backJwt"),
},
})
.then((res) => {
const json = {};
if (res.status !== 200) {
failure("HTTP Error: " + res.data.msg);
return;
}
// json = JSON.parse(res)
json.location = res.data.data?.image_url;
if (!json || typeof json.location !== "string") {
failure("Error:" + res.data.msg);
return;
}
success(json.location);
});
});
},
mouseOver(val) {
val.isShowBtn = true;
this.$forceUpdate();
},
mouseLeave(val) {
val.isShowBtn = false;
this.$forceUpdate();
},
autoRefresh() {
setInterval(() => {
this.getOrderDetailData();
}, 1000 * 60);
},
initViewer() {
this.viewer = new Viewer(document.getElementById("viewer"), {
button: true,
inline: false,
zoomable: true,
title: true,
tooltip: true,
minZoomRatio: 0.5,
maxZoomRatio: 100,
movable: true,
interval: 2000,
navbar: true,
loading: true,
});
},
},
created() {
this.getOrderDetailData();
this.autoRefresh();
this.getTicketLog();
this.getTicketPrereply();
},
mounted() {
this.initTemplate();
this.initViewer();
},
}).$mount(template);
typeof old_onload == "function" && old_onload();
};
})(window);

View File

@@ -0,0 +1,826 @@
(function (window, undefined) {
var old_onload = window.onload;
window.onload = function () {
const template = document.getElementsByClassName("template")[0];
Vue.prototype.lang = Object.assign(window.lang, window.plugin_lang);
const host = location.origin;
const fir = location.pathname.split("/")[1];
const str = `${host}/${fir}/`;
new Vue({
components: {
comConfig,
comTinymce,
opinionButton,
},
data () {
return {
message: "template...",
// 工单类型数据
orderTypeData: [],
prereplyContent: "",
// 工单类型下拉框
orderTypeOptions: [],
popupVisible: false,
// 工单状态数据
orderStatusData: [],
// 工单部门
departmentList: [],
// 预设回复列表
prereplyList: [],
deliveryLoading: false,
subDeliveryLoading: false,
deliverDiaVisible: false,
editReplayItem: {},
deliverForm: {
product_ids: [],
ticket_type_id: "",
blocked_words: "",
},
deliverVisile: false,
// 完结状态下拉框
statusOpitons: [
{
statusText: lang.order_text63,
status: 1,
},
{
statusText: lang.order_text64,
status: 0,
},
],
// 指定部门下拉框数据(管理员分组列表数据)
departmentOptions: [],
// 指定人员下拉框数据(分组下管理员)
adminsOptions: [],
// 所有人员数据
adminList: [],
isSubmit: false,
isSubStatus: false,
isUpdateType: false,
isUpdateStatus: false,
isAddType: false,
isAddStatus: false,
isEditReply: false,
deleteVisible: false,
editId: null,
delId: null,
isAddReply: false,
saveLoading: false,
deliveryProductList: [],
columns: [
{
colKey: "name",
title: lang.order_text65,
cell: "name",
minWidth: "300",
},
{
colKey: "admin",
title: lang.order_text66,
cell: "department",
minWidth: "300",
},
{
colKey: "op",
title: lang.order_text67,
cell: "op",
width: "100",
},
],
columns2: [
{
colKey: "index",
title: lang.order_text68,
cell: "index",
width: "193",
},
{
colKey: "name",
title: lang.order_text69,
cell: "name",
},
{
colKey: "color",
title: lang.order_text70,
cell: "color",
width: "302",
},
{
colKey: "statusText",
title: lang.order_text71,
cell: "status",
width: "302",
},
{
colKey: "op",
title: lang.order_text67,
cell: "op",
width: "100",
fixed: "right",
},
],
columns3: [
{
colKey: "content",
title: lang.order_text72,
cell: "content",
},
{
colKey: "op",
title: lang.order_text67,
cell: "op",
width: "100",
fixed: "right",
},
],
configObj: {
refresh_time: "",
ticket_notice_open: 0,
ticket_notice_description: "",
ticket_type_id: "",
downstream_delivery: 0,
ticket_close_hour: null,
ticket_close_switch: 0,
},
submitLoading: false,
deliveryList: [],
columns4: [
{
colKey: "product_name",
title: lang.order_text91,
cell: "product_name",
ellipsis: true,
},
{
colKey: "type_name",
title: lang.order_text92,
cell: "type_name",
ellipsis: true,
},
{
colKey: "blocked_words",
title: lang.order_text93,
cell: "blocked_words",
ellipsis: true,
},
{
colKey: "op",
title: lang.order_text67,
cell: "op",
width: "100",
fixed: "right",
},
],
rules: {
product_ids: [
{
required: true,
message: lang.order_text91,
type: "error",
},
],
ticket_type_id: [
{
required: true,
message: lang.order_text92,
type: "error",
},
],
},
};
},
computed: {},
computed: {
calcName () {
return (arr) => {
if (arr.length > 0) {
const temp = arr.reduce((all, cur) => {
all.push(cur.name);
return all;
}, []);
return temp.join("");
}
return "";
};
},
calcId () {
return (arr) => {
const temp = arr.reduce((all, cur) => {
all.push(cur.id);
return all;
}, []);
return temp;
};
},
},
methods: {
deliverFormSubmit ({ validateResult, firstError }) {
if (validateResult === true) {
this.subDeliveryLoading = true;
const subApi = this.editId ? apieditDelivery : apiAddDelivery;
const params = {
id: this.editId,
...this.deliverForm,
};
if (this.editId) {
params.product_id = params.product_ids[0];
}
subApi(params)
.then((res) => {
this.subDeliveryLoading = false;
this.deliverVisile = false;
this.$message.success(res.data.msg);
this.getDeliveryList();
})
.catch((err) => {
this.subDeliveryLoading = false;
this.$message.error(err.data.msg);
});
} else {
this.$message.warning({
content: firstError,
placement: "top-right",
});
}
},
getDeliveryProductList () {
apiDeliveryProductList().then((res) => {
this.deliveryProductList = res.data.data.list
.map((item, index) => {
item.label = item.supplier_name;
item.value = item.supplier_name + index;
item.children = item.group.map((items, indexs) => {
items.label = items.product_group_name;
items.value =
items.product_group_name + indexs + item.supplier_name;
items.children = items.products.map((product) => {
product.label = product.product_name;
product.value = product.product_id;
return product;
});
return items;
});
return item;
})
.filter((item) => item.children.length > 0);
});
},
addDelivery () {
this.editId = null;
this.deliverForm = {
product_ids: [],
ticket_type_id: "",
blocked_words: "",
};
this.deliverVisile = true;
},
editDelivery (row) {
apiDeliveryDetail({ id: row.id }).then((res) => {
this.editId = row.id;
this.deliverForm = {
product_ids: [res.data.data.ticket_delivery.product_id],
ticket_type_id: res.data.data.ticket_delivery.ticket_type_id,
blocked_words: res.data.data.ticket_delivery.blocked_words,
};
this.deliverVisile = true;
});
},
deleteDelivery (row) {
this.delId = row.id;
this.deleteVisible = true;
},
handelDelete () {
this.deliveryLoading = true;
apiDelDelivery({ id: this.delId })
.then((res) => {
this.deliveryLoading = false;
this.deleteVisible = false;
this.$message.success(res.data.msg);
this.getDeliveryList();
})
.catch((err) => {
this.deliveryLoading = false;
this.$message.error(err.data.msg);
});
},
getDeliveryList () {
apiDeliveryList().then((res) => {
this.deliveryList = res.data.data.list;
});
},
async getConfig () {
try {
const res = await getOrderConfig();
this.configObj = res.data.data;
this.$refs.comTinymce.setContent(
this.configObj.ticket_notice_description
);
} catch (error) { }
},
async saveConfig () {
try {
this.submitLoading = true;
// const content = tinyMCE.editors[1].getContent();
const content = this.$refs.comTinymce.getContent();
const params = { ...this.configObj };
params.ticket_notice_description = content;
const res = await saveOrderConfig(params);
this.$message.success(res.data.msg);
this.submitLoading = false;
this.getConfig();
} catch (error) {
this.$message.error(error.data.msg);
}
},
// 初始化富文本
initTemplate () {
tinymce.init({
selector: "#tiny",
language_url: "/tinymce/langs/zh_CN.js",
language: "zh_CN",
min_height: 400,
width: "100%",
plugins:
"link lists image code table colorpicker textcolor wordcount contextmenu fullpage paste",
toolbar:
"bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent blockquote | undo redo | link unlink image fullpage code | removeformat",
images_upload_url: str + "v1/upload",
paste_data_images: true,
convert_urls: false,
//粘贴图片后,自动上传
urlconverter_callback: function (url, node, on_save, name) {
return url;
},
images_upload_handler: this.handlerAddImg,
});
tinymce.init({
selector: "#ticketNoticeTiny",
language_url: "/tinymce/langs/zh_CN.js",
language: "zh_CN",
min_height: 400,
width: "100%",
plugins:
"link lists image code table colorpicker textcolor wordcount contextmenu fullpage paste",
toolbar:
"bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent blockquote | undo redo | link unlink image fullpage code | removeformat",
images_upload_url: str + "v1/upload",
paste_data_images: true,
convert_urls: false,
//粘贴图片后,自动上传
urlconverter_callback: function (url, node, on_save, name) {
return url;
},
images_upload_handler: this.handlerAddImg,
});
},
// 富文本上传图片
handlerAddImg (blobInfo, success, failure) {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append("file", blobInfo.blob());
axios
.post(`${str}v1/upload`, formData, {
headers: {
Authorization:
"Bearer" + " " + localStorage.getItem("backJwt"),
},
})
.then((res) => {
const json = {};
if (res.status !== 200) {
failure("HTTP Error: " + res.data.msg);
return;
}
// json = JSON.parse(res)
json.location = res.data.data?.image_url;
if (!json || typeof json.location !== "string") {
failure("Error:" + res.data.msg);
return;
}
success(json.location);
});
});
},
// 添加工单类型
appendToRoot () {
if (this.isUpdateType || this.isAddType) {
return this.$message.error(lang.please_save);
}
this.orderTypeData.push({
isedit: false,
name: "",
isAdd: true,
arr: [],
arr1: [],
});
this.isAddType = true;
},
// 获取工单类型数据
getOrderTypeOptions () {
getUserOrderType()
.then((result) => {
this.orderTypeOptions = result.data.data.list.map((item) => {
return { name: item.name };
});
this.getDepartmentOptions();
this.orderTypeData = result.data.data.list.map((item) => {
item.isedit = false;
item.status = "edit";
item.admin_role_id = 0;
// // 设置选中的管理员id
const temp = item.admin.reduce((all, cur) => {
all.push(cur.id);
return all;
}, []);
item.arr = temp;
item.arr1 = temp;
return item;
});
})
.catch();
},
onPopupVisibleChange (val) {
this.popupVisible = val;
},
onClear (row) {
row.name = "";
},
onOptionClick (item, row) {
row.name = item;
this.popupVisible = false;
},
onInputChange (val, row) {
row.name = val;
},
// 编辑
edithandleClickOp (id) {
if (this.isUpdateType) {
return this.$message.error(lang.please_save);
}
this.isUpdateType = true;
for (let i = 0; i < this.orderTypeData.length; i++) {
if (id === this.orderTypeData[i].id) {
this.$set(this.orderTypeData[i], "isedit", true);
}
}
},
// 工单-工单类型管理-删除
async orderTypeMgtDelete (row) {
const result = await orderTypeDelete(row.id);
if (result.status === 200) {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getOrderTypeOptions();
} else {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
}
},
// 取消新增类型
deleteClickadd () {
this.orderTypeData.pop();
this.isAddType = false;
},
//取消修改
canceledit (item) {
this.isUpdateType = false;
item.arr1 = item.arr;
this.getOrderTypeOptions();
},
// 工单-工单类型管理-保存
async orderTypeMgtSave (row) {
if (row.arr1.length === 0 || !row.name) {
this.$message.warning({
content: lang.order_type_verify1,
placement: "top-right",
});
return;
}
const params = {
admin_id: row.arr1,
name: row.name,
};
if (this.isSubmit) {
return;
}
this.isSubmit = true;
if (row.status === "edit") {
params.id = row.id;
await orderTypeEdit(row.id, params)
.then((result) => {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getOrderTypeOptions();
})
.catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
});
} else {
await orderTypeAdd(params)
.then((result) => {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getOrderTypeOptions();
})
.catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
});
}
this.isSubmit = false;
this.isUpdateType = false;
this.isAddType = false;
},
// 删除
deleteClickOp (id) {
deletehelptype({ id })
.then((res) => {
this.$message.success(res.data.msg);
this.getOrderTypeOptions();
})
.catch((err) => {
this.$message.error(err.data.msg);
});
},
// 工单-转内部-选择部门变化
departmentChange (val, item) {
// 获取部门id对应部门名称
// const department = this.departmentOptions.filter(item => item.id === val)[0];
// const name = department ? department.name : null;
// const optionList = [];
// // 清除已选人员数据
// this.adminList.forEach(item => {
// if (name && item.roles === name) {
// optionList.push(item);
// }
// });
// this.adminsOptions = optionList;
item.arr1 = val;
},
// 获取工单状态列表
getTicketStatus () {
ticketStatus().then((res) => {
res.data.data.list.forEach((item, index) => {
if (item["default"] === 1) {
item.noEdit = true;
}
if (item["status"] === 1) {
item.statusText = lang.order_text63;
} else if (item["status"] === 0) {
item.statusText = lang.order_text64;
} else {
item.statusText = "--";
}
delete item["default"];
item.index = index + 1;
item.isedit = false;
});
this.orderStatusData = res.data.data.list;
});
},
// 编辑状态
editStatus (row) {
if (this.isUpdateStatus) {
return this.$message.error(lang.please_save);
}
if (row.noEdit) {
return this.$message.error(lang.order_text73);
}
this.isUpdateStatus = true;
for (let i = 0; i < this.orderStatusData.length; i++) {
if (row.id === this.orderStatusData[i].id) {
this.$set(this.orderStatusData[i], "isedit", true);
}
}
},
// 保存状态
async orderStatustSave (row) {
console.log(row);
if (!row.name || !row.color || row.status === "") {
this.$message.warning({
content: lang.order_text74,
placement: "top-right",
});
return;
}
const params = {
name: row.name,
color: row.color,
status: row.status,
};
if (this.isSubStatus) {
return;
}
this.isSubStatus = true;
if (row.isedit) {
params.id = row.id;
await editTicketStatus(params)
.then((result) => {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getTicketStatus();
})
.catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
});
} else {
await addTicketStatus(params)
.then((result) => {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getTicketStatus();
})
.catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
});
}
this.isSubStatus = false;
this.isUpdateStatus = false;
this.isAddStatus = false;
},
// 添加工单状态
appendStatus () {
if (this.isUpdateStatus || this.isAddStatus) {
return this.$message.error(lang.please_save);
}
const index = this.orderStatusData.length + 2;
this.orderStatusData.push({
isedit: false,
name: "",
isAdd: true,
index: index,
});
this.isAddStatus = true;
},
// 工单状态删除
async orderStatusMgtDelete (row) {
if (row.noEdit) {
return this.$message.error(lang.order_text75);
}
const result = await deleteTicketStatus(row.id).catch((result) => {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
});
if (result.status === 200) {
this.$message.success({
content: result.data.msg,
placement: "top-right",
});
this.getTicketStatus();
} else {
this.$message.warning({
content: result.data.msg,
placement: "top-right",
});
}
},
// 取消新增状态
deleteStatusadd () {
this.orderStatusData.pop();
this.isAddStatus = false;
},
// 取消修改状态
cancelStatusEdit () {
this.isUpdateStatus = false;
this.getTicketStatus();
},
// 工单-转发-选择人员变化
adminChange (val) {
this.$forceUpdate();
},
// 获取部门数据
getDepartmentOptions () {
getAdminList({ page: 1, limit: 10000 })
.then((result) => {
this.departmentOptions = result.data.data.list;
this.orderTypeData.forEach((item, index) => {
this.departmentOptions.forEach((items) => {
if (item.role_name === items.name) {
item.admin_role_id = items.id;
}
});
});
})
.catch();
},
// 获取人员数据
getAdminList () {
getAdminList({ page: 1, limit: 10000 })
.then((result) => {
this.adminList = result.data.data.list;
})
.catch();
},
// 时间格式转换
formatDate (dateStr) {
const date = new Date(dateStr * 1000);
const str1 = [
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
].join("-");
const str2 = [
this.formatDateAdd0(date.getHours()),
this.formatDateAdd0(date.getMinutes()),
this.formatDateAdd0(date.getSeconds()),
].join(":");
return str1 + " " + str2;
},
formatDateAdd0 (m) {
return m < 10 ? "0" + m : m;
},
// 获取工单预设回复列表
getTicketPrereply () {
ticketPrereply().then((res) => {
this.prereplyList = res.data.data.list;
});
},
// 编辑预设回复
editPrereply (row) {
if (this.isEditReply) {
return this.$message.error(lang.order_text76);
}
this.isEditReply = true;
//tinyMCE.editors[0].setContent(row.content);
this.prereplyContent = row.content;
this.$refs.comTinymce1.setContent(row.content);
this.editReplayItem = row;
},
// 删除预设回复
async deletePrereply (row) {
if (this.isEditReply) {
return this.$message.error(lang.order_text76);
}
await deleteTicketPrereply(row.id);
this.getTicketPrereply();
},
// 保存预设回复
async savePreReplay () {
this.saveLoading = true;
// const content = tinyMCE.editors[0].getContent();
const content = this.$refs.comTinymce1.getContent();
const params = {
content: content,
};
// 编辑
if (this.isEditReply) {
params.id = this.editReplayItem.id;
await editTicketPrereply(params);
this.isEditReply = false;
this.$refs.comTinymce1.setContent(" ");
this.getTicketPrereply();
} else {
await addTicketPrereply(params);
this.$refs.comTinymce1.setContent(" ");
this.getTicketPrereply();
}
this.saveLoading = false;
},
},
created () {
this.getOrderTypeOptions();
this.getTicketStatus();
this.getTicketPrereply();
this.getConfig();
this.getDeliveryList();
this.getDeliveryProductList();
},
mounted () {
// this.initTemplate();
},
}).$mount(template);
typeof old_onload == "function" && old_onload();
};
})(window);

File diff suppressed because one or more lines are too long