// ==UserScript== // @name 蒙天致远OA-UI // @namespace https://scriptcat.org/ // @description 基于Arco做的UI库, 用于快速开发脚本的UI界面 // @version 1.0.5 // @author empyrealtear // @match *://oa.mengtiandairy.com:7070/* // @require https://scriptcat.org/lib/1167/1.0.0/%E8%84%9A%E6%9C%AC%E7%8C%ABUI%E5%BA%93.js // @require https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js // @require https://scriptcat.org/lib/1620/1.4.0/json-bigint-parser-browser.js // @require https://scriptcat.org/lib/1492/1.0.0/seatable.js // @require https://cdn.bootcdn.net/ajax/libs/jszip/3.7.1/jszip.min.js // @require https://cdn.bootcdn.net/ajax/libs/nanobar/0.4.2/nanobar.min.js // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @grant GM_openInTab // @grant GM_info // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_cookie // @noframes // ==/UserScript== //暴露变量 方便调试 const ast = new CAT_UI(); (window.unsafeWindow || window).CAT_UI = CAT_UI; (window.unsafeWindow || window).React = React; (window.unsafeWindow || window).ReactDOM = ReactDOM; (window.unsafeWindow || window).jsxLoader = jsxLoader; (window.unsafeWindow || window).ast = ast; // 综合面板 var config = {} if (GM_getValue('config') == null) { config = { userIds: { 'gaoym(出纳)': '-8621888980617641168', 'guoxb(财务经理)': '4316820462592411342', 'zhangxh(离职经理)': '1689005231439299871', 'guocj(费用)': '-5164055170059383110', 'zhangxq(成本)': '-8049862802055871402', 'zhousj(费用)': '4358742559322622933', 'lixh(费用)': '-7508643625564552124', // 'hourf(行政经理)': '7003896008754152897', // 'xingyy(行政专员)': '-1479069870384263788', // 'liml(财务总监)': '-7379722041914604384', // 'yaoyz(离职法人)': '-3960868405333900662', // 'lihn(离职工程经理)': '3445155532489703504' }, types: { '已办': 'done', '待办': 'pending', '已发': 'sent', '督办': 'supervise', '跟踪': 'track', }, data: { userId: '-5164055170059383110', type: 'pending', pageable: true }, seatable: { 'server': 'http://26.25.156.106', 'APIToken': 'd206902a1d886db445d7d0c008004f962731de1b', 'asycn': false, 'skip': true } } } else { config = JSON.parse(GM_getValue('config')) } const utils = { getValue: (key) => GM_getValue(key), setValue: (key, val) => GM_setValue(key, val), loadScript: (url, callback) => { var script = document.createElement("script") script.type = "text/javascript" if (typeof (callback) != "undefined") if (script.readyState) script.onreadystatechange = () => { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null callback() } } else script.onload = () => callback() script.src = url document.body.appendChild(script) }, fetchBlob: async (fetchUrl, method = "POST", body = null, header = null) => { const response = await window.fetch(fetchUrl, { method, body: body ? JSON.stringify(body) : null, headers: header ? header : {}, }) const blob = await response.blob() return blob }, downloadFile: (blob, fileName) => { const a = document.createElement('a') a.style.display = 'none' a.href = window.URL.createObjectURL(blob) a.download = fileName document.body.appendChild(a) a.click() document.body.removeChild(a) }, generateZip: async (files, name = null) => { const zip = new JSZip() files.forEach((item) => zip.file(item.name, item.blob, { binary: true })) const content = await zip.generateAsync({ type: "blob" }) const currentDate = new Date().getTime() const fileName = name ? name : `zipped-${currentDate}.zip` return utils.downloadFile(content, fileName) }, asyncPool: async (arr, delegate, start = (v) => v, end = (v) => v, poolLimit = 5) => { const ret = [] const executing = new Set() let arr_res = new Array(arr.length) let completeCount = 0 var nanobarid = 'nanobar' var nanobar = new Nanobar({ id: nanobarid, target: document.body }) $(`#${nanobarid}`).css('background', '#BEE7E9') $(`#${nanobarid} .bar`).css('background', '#F4606C') arr = start(arr) for (let [index, item] of arr.entries()) { const p = Promise.resolve().then(async () => { try { var res = await delegate(item, arr) arr_res[index] = res } catch (err) { console.warn(err) arr_res[index] = err } return }).finally(() => { nanobar.go((++completeCount) / arr.length * 100) }) ret.push(p) executing.add(p) const clean = () => executing.delete(p) p.then(clean).catch(clean) if (executing.size >= poolLimit) { await Promise.race(executing) } } return Promise.all(ret).then(() => { $(`#${nanobarid}`).remove() console.log(arr_res) console.log(completeCount) return end(arr_res) }) }, clearDuplicate: (arr, key) => Array.from(new Set(arr.map(e => e[key]))).map(e => arr.find(x => x[key] == e)) } const seeyouUtils = { // 获取表单数据 getformdata: (id) => { var res = null $.ajax({ url: `/seeyon/rest/form/getformdata/${id}`, method: "GET", async: false, dataType: 'json', dataFilter: (data, type) => { if (type == 'json') { return JSONbig.stringify(JSONbig.parse(data)) } return data } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (flowId='${id}') Unable to get formdata. `) }) return res }, // 获取正文数据 data: (id) => { var res = null $.ajax({ url: `/seeyon/rest/flow/data/${id}?exportType=0&exportFormat=json`, method: "GET", async: false, dataType: 'json', dataFilter: (data, type) => { if (type == 'json') { return JSONbig.stringify(JSONbig.parse(data)) } return data } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (flowId='${id}') Unable to get formdata. `) }) return res }, // 获取附件列表 attachments: (summaryId, attType = '0,2') => { var res = null $.ajax({ url: `/seeyon/rest/coll/attachments/${summaryId}/${attType}`, method: "GET", async: false, dataType: 'json', dataFilter: (data, type) => { if (type == 'json') { return JSONbig.stringify(JSONbig.parse(data)) } return data } }).success((e) => { res = $.map(e, (v) => { v['downloadUrl'] = `http://oa.mengtiandairy.com:7070/seeyon/fileDownload.do?method=doDownload&filename=${encodeURI(v.filename)}&v=${v.v}&fileId=${v.fileUrl}` return v }) }).error((e) => { console.log(`[seeyou] (flowId='${summaryId}') Unable to get attachments. `) }) return res }, // 获取流程状态 state: (summaryId) => { var res = { id: summaryId, state: null, value: null } const stateEnum = { 1: '待发', 3: '待处理', 4: '处理中', 6: '回退', 7: '取回', 5: '撤销', 15: '终止', 0: '结束' } $.ajax({ url: `/seeyon/rest/flow/state/${summaryId}`, method: "GET", async: false }).success((e) => { res.state = e res.value = stateEnum[e] }).error((e) => { console.log(`[seeyou] (flowId='${summaryId}') Unable to get state. `) }) return res }, // 获取流程待办人列表 dostaff: (summaryId) => { var res = null $.ajax({ url: `/seeyon/rest/flow/dostaff/${summaryId}`, method: "GET", async: false, dataType: 'json', dataFilter: (data, type) => { if (type == 'json') { return JSONbig.stringify(JSONbig.parse(data)) } return data } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (flowId='${summaryId}') Unable to get dostaff. `) }) return res }, // 获取指定人员协同列表, 已办=done、待办=pending、已发=sent、督办=supervise、跟踪=track getaffairs: (id, type, pageNo = 1, pageSize = 20) => { var res = null $.ajax({ url: `/seeyon/rest/affairs/${type}?memberId=${id}&pageNo=${pageNo}&pageSize=${pageSize}`, method: "GET", async: false, dataType: 'json', dataFilter: (data, type) => { if (type == 'json') { return JSONbig.stringify(JSONbig.parse(data)) } return data } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (memberid='${id}') Unable to get ${type} list. `) }) return res }, // 搜索联系人 getaddressbook: (searchContent) => { var res = {} $.ajax({ url: `/seeyon/addressbook.do?method=listAllMembers&showType=list&searchContent=${encodeURIComponent(searchContent)}`, method: "GET", async: false, dataType: 'html', dataFilter: (data, type) => { console.log(type) if (type == 'html') return $(data).find('#bTablememberlist #bodyIDmemberlist input[type=hidden]') return data } }).success((e) => { e.each((i, v) => res[v.id.replace(/_Name$/, '')] = v.value) }).error((e) => { console.log(`[seeyou] (searchContent='${searchContent}') Unable to find. `) }) return res }, // 获取成员信息 getMemberInfoById: (memberId) => { var res = null $.ajax({ url: `/seeyon/addressbook.do?method=getMemberInfoById`, method: "POST", data: { memberId: memberId }, async: false, dataType: 'json', dataFilter: (data, type) => { return data } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (memberId='${memberId}') Unable to getMemberInfoById. `) }) return res }, // 显示审批进度 showDetailLogDialog: (summaryId) => { unsafeWindow.$.dialog({ url: `http://oa.mengtiandairy.com:7070/seeyon/detaillog/detaillog.do?method=showDealingLog&summaryId=${summaryId}`, width: 1040, height: 480, title: unsafeWindow.$.i18n('collaboration.sendGrid.findAllLog'), //查看明细日志 targetWindow: getCtpTop() }) }, // 获取审批意见 findsSummaryComments: (moduleId, affairId, page = 1, pageSize = 500) => { var res = null $.ajax({ url: 'http://oa.mengtiandairy.com:7070/seeyon/ajax.do?method=ajaxAction&managerName=colManager', method: 'POST', async: false, data: { managerMethod: 'findsSummaryComments', arguments: JSON.stringify([{ isHistory: 'false', moduleId: moduleId, affairId: affairId, page: page.toString(), pageSize: pageSize.toString(), queryType: '0' }]) } }).success((e) => { res = e }).error((e) => { console.log(`[seeyou] (moduleId='${memberId}', affairId='${affairId}') Unable to findsSummaryComments. `) }) return res }, // 转发协同 transmitColById: (data) => { var doForwardData = "" for (var i = 0; i < data.length; i++) { doForwardData += data[i]["objectId"] + "_" + data[i]["id"] + "," } var dialog = unsafeWindow.$.dialog({ id: "showForwardDialog", height: "400", width: "550", url: "/seeyon/collaboration/collaboration.do?method=showForward&data=" + doForwardData, title: $.i18n('common.toolbar.transmit.col.label'), targetWindow: unsafeWindow.getCtpTop(), isClear: false, transParams: { commentContent: "" }, buttons: [ { id: "okButton", text: $.i18n("common.button.ok.label"), btnType: 1, handler: function () { var rv = dialog.getReturnValue(); }, OKFN: () => dialog.close() }, { id: "cancelButton", text: $.i18n("common.button.cancel.label"), handler: () => dialog.close() } ] }) } } const loopUserAffairs = async (userId, type = 'pending') => { const table_name = "流程" const templateFields = { // 对外付款申请单 '5895142011406796749': { 'supplyName': 'field0044', 'applyAmount': 'field0054', 'account': ['field0066', 'field0065', 'field0047'], 'depositBank': 'field0046', 'payer': 'field0021', 'flowType': '往来' }, // 牧业事业部请付款审批单 '-1910116541235311711': { 'supplyName': 'field0046', 'applyAmount': 'field0039', 'account': 'field0048', 'depositBank': 'field0047', 'payer': 'field0041', 'flowType': '往来' }, // 差旅费报销单V2 '-2533668926056086008': { 'supplyName': 'field0040', 'applyAmount': 'field0039', 'payer': 'field0021', 'flowType': '往来' }, // 差旅费报销单 '-4446069144704102606': { 'supplyName': 'field0040', 'applyAmount': 'field0039', 'payer': 'field0021', 'flowType': '往来' }, // 油费报销单V2 '8076215884574836222': { 'supplyName': 'field0040', 'applyAmount': 'field0054', 'payer': 'field0021', 'flowType': '往来' }, // 油费报销单 '-7135341086229641970': { 'supplyName': 'field0040', 'applyAmount': 'field0054', 'payer': 'field0021', 'flowType': '往来' }, // 其他费用报销单V2 '4291802339177547763': { 'supplyName': 'field0044', 'applyAmount': 'field0039', 'account': 'field0046', 'depositBank': 'field0045', 'payer': 'field0021', 'flowType': '往来' }, // 借款申请单 '-629130699976915145': { 'supplyName': 'field0044', 'applyAmount': 'field0054', 'account': 'field0047', 'depositBank': 'field0046', 'payer': 'field0021', 'flowType': '往来' }, // 薪酬费用付款单 '4289674701592086231': { 'supplyName': ['field0048', 'field0049', 'field0050', 'field0051', 'field0052', 'field0067'], 'applyAmount': 'field0065', 'payer': '', 'flowType': '往来' }, // 费用报销单 '-2965283357942464048': { 'supplyName': 'field0044', 'applyAmount': 'field0039', 'payer': 'field0021', 'flowType': '往来' }, // 牧场-存货采购申请 '-3488430484073462403': { 'flowType': '申请' }, // 固定资产采购申请 '1141314162835736270': { 'flowType': '申请' }, // 低值易耗品采购申请单 '5716260486623544296': { 'flowType': '申请' }, // 招待费用申请表 '8176611886140900716': { 'flowType': '申请' }, // 印章使用审批单 '1767375867302135476': { 'flowType': '用章' }, // 蒙天乳业法律纠纷处理申请单 '-3115139038453937530': { 'flowType': '申请' }, // 办公设施维修申请单 '-632475279924901446': { 'flowType': '申请' }, // 用车申请表 '-8533694493240833303': { 'flowType': '申请' }, // 请假(调休)单 '8445585496425120712': { 'flowType': '申请' }, // 离职申请表 '-7021572671665651605': { 'flowType': '申请' }, // 出差申请单 '-8958950164829159336': { 'flowType': '申请' }, // 招聘需求申请表New '4640646536853408321': { 'flowType': '申请' }, // 人员转正申请单 '7170683882049914937': { 'flowType': '申请' }, // OA流程变更申请单 '-7984124277308504018': { 'flowType': '申请' }, // 薪酬审批流程 '-3617308359877440598': { 'flowType': '申请' }, // 合同审批单 '-6320528816474667249': { 'supplyName': 'field0007', 'payer': 'field0006', 'flowType': '合同' }, // 市场类合同审批单 '-1013128023555421549': { 'supplyName': 'field0007', 'payer': 'field0006', 'flowType': '合同' }, // 采购合同审批单(工厂) '8459265283253290318': { 'supplyName': 'field0007', 'payer': 'field0006', 'flowType': '合同' }, // 采购合同审批单(牧场) '5241894685812869986': { 'supplyName': 'field0007', 'payer': 'field0006', 'flowType': '合同' }, // 合同审批单 '1324051725902628863': { 'supplyName': 'field0007', 'payer': 'field0006', 'flowType': '合同' }, } const payerEnum = { // 费用承担公司id "-1585937216510934337": "蒙天乳业有限公司", "4663292034364819526": "山东蒙天乳业有限公司", "6596440339473514738": "蒙天乳业有限公司上海分公司", "-1528005668975521993": "江西蒙天乳业有限公司", "-1557708275488174959": "宁夏蒙天乳业有限公司", "6904505186630389404": "德州市维多利亚农牧有限公司", "8584309132117690151": "山东东君生态农业有限公司", "514582257443029538": "健康饮品事业部华东大区", "-1853804211592082200": "健康饮品事业部华北大区", "2761474216853258980": "健康饮品事业部华中大区", "1960492753753950438": "健康饮品事业部华南大区", "7445807672464326991": "健康饮品事业部西北大区", "-6923534789795690870": "蒙天乳业有限公司南昌分公司", "-7429051204531565381": "健康饮品事业部苏皖沪大区", "-8111400422124074379": "健康饮品事业部新品部", // 部门id "-3183965678221049613": "山东东君生态农业有限公司" } var page = 1, size = 200, arr = [] do { var table = { update: [], append: [] } var res = seeyouUtils.getaffairs(userId, type, page, size) arr.push(...res.data) page += 1 } while (res.data.length >= size) arr = utils.clearDuplicate(arr, 'objectId') if (config.seatable.skip) return arr var databaseRes = [], listrows const seatable_base = new Base(config.seatable) await seatable_base.auth() do { listrows = await seatable_base.queryAsync(`select * from ${table_name} limit 5000 offset ${databaseRes.length}`) databaseRes.push(...listrows) } while (listrows != null && listrows.length > 0) let resdict = {} $.each(databaseRes, (i, v) => resdict[v['ID']] = v) return await utils.asyncPool(arr, async (val) => { let row = { 'ID': val['objectId'], '模板ID': val['templeteId'], '协同ID': val['id'], '表单ID': val['formRecordid'], '标题': val['subject'], '发起人': val['senderName'] } if (val['objectId'] in resdict) { let row_update_simplify = {} let rowpre = resdict[val['objectId']] Object.entries(row).forEach(([k, v], i) => { if (rowpre[k] != v) row_update_simplify[k] = v }) if (Object.keys(row_update_simplify).length > 0) table.update.push({ row_id: rowpre['_id'], row: row_update_simplify }) Object.entries({ 'payer': '付款方', 'supplyName': '收款账户', 'account': '银行账号', 'depositBank': '开户行', 'applyAmount': '申请金额', 'accountPayable': '应付金额', 'paidAmount': '已付金额', 'unpaidAmount': '未付金额', 'financeId': '核销凭证' }).forEach(([k, v], i) => { val[k] = rowpre[v] }) } else { let formdata = seeyouUtils.getformdata(val['objectId']) let templete = templateFields[val['templeteId']] if (templete) { let data = formdata.DataMap Object.entries(templete).forEach(([k, v], i) => { if (v instanceof Array) { v.some(x => { if (data[x] == null || data[x] == '') return false else { val[k] = data[x] return true } }) } else if (v.startsWith('field')) { val[k] = data[v] } else { val[k] = v } }) } let rowappend = Object.assign({}, row, { '发起日期': (new Date(val['createDate'])).format('yyyy-MM-dd HH:mm'), '付款方': payerEnum.hasOwnProperty(val['payer']) ? payerEnum[val['payer']] : /生态农业/.test(val['subject']) ? '山东东君生态农业有限公司' : '德州市维多利亚农牧有限公司', '收款账户': /-?[0-9]+$/.test(val['supplyName']) ? seeyouUtils.getMemberInfoById(val['supplyName'])['memberName'] : val['supplyName'], '银行账号': val['account'], '开户行': val['depositBank'], '申请金额': val['applyAmount'], '应付金额': val['applyAmount'], '已付金额': 0 }) if (val['flowType'] != null) { rowappend['类型'] = val['flowType'] } table.append.push(rowappend) } return val }, (v) => v, (v) => { console.log(table) if (config.seatable.asycn) { let batchsize = 200 let batchpage, batchrows if (table.update.length > 0) { batchpage = 1 do { batchrows = table.update.slice(batchsize * (batchpage - 1), batchsize * batchpage) seatable_base.batchUpdateRows(table_name, batchrows) batchpage += 1 } while (batchrows.length >= batchsize) } if (table.append.length > 0) { batchpage = 1 do { batchrows = table.append.slice(batchsize * (batchpage - 1), batchsize * batchpage) seatable_base.batchAppendRows(table_name, batchrows) batchpage += 1 } while (batchrows.length >= batchsize) } } // console.log(v) return v }) } const options = { menus: { minSwitch: { toStr: (x) => '窗口模式:' + (x ? '最小化' : '展开(原模式)'), register: () => { let ismin = utils.getValue('ismin') options.menus.minSwitch[!ismin ? '_new' : '_old'] = GM_registerMenuCommand(options.menus.minSwitch.toStr(ismin), () => { utils.setValue('ismin', !ismin) options.menus.minSwitch.register() }) GM_unregisterMenuCommand(options.menus.minSwitch[ismin ? '_new' : '_old']) }, _new: null, _old: null }, }, register: () => { options.menus.minSwitch.register() } } options.register() unsafeWindow.seeyouUtils = seeyouUtils // 协同面板 function initTable() { let tbData let selectedRowKeys, setSelectedRowKeys let currentSelectedRows = [] let data, setData let pagination = { sizeCanChange: true, showTotal: true, total: 0, pageSize: 15, current: 1, sizeOptions: [15, 20, 50, 100, 500, 1000, 5000, 100000], pageSizeChangeResetCurrent: true, sizeCanChange: true, showJumper: true, itemRender: (page, type, originElement) => { if (type === 'prev') return CAT_UI.el('a', {}, '上一页') if (type === 'next') return CAT_UI.el('a', {}, '下一页') return originElement } } let isloading = false let attrs = {} let states = {} let init = false const expandedRow_attachments = (val) => { let flowid = val['objectId'] let col_attrs = [ { title: '文件名', dataIndex: 'filename' }, { title: '操作', dataIndex: 'downloadUrl', align: 'center', render: (col, record, index) => [ CAT_UI.Button('下载', { href: record.downloadUrl, size: 'mini' }), CAT_UI.Button('预览', { size: 'mini', onClick: () => { if (record.extension == 'pdf') unsafeWindow.preViewDialog(`/seeyon/fileDownload.do?method=doDownload4Office&type=Pdf&isOpenFile=true&fileId=${record.fileUrl}&filename=${record.filename}&v=${record.v}&`) else if (record.extension == 'jpg' || record.extension == 'png') unsafeWindow.preViewDialog(`/seeyon/fileUpload.do?method=showRTE&type=image&fileId=${record.fileUrl}&filename=${record.filename}&v=${record.v}`) else if (record.officeTransformEnable == 'enable') unsafeWindow.preViewDialog(`/seeyon/officeTrans.do?method=view&fileId=${record.fileUrl}&filename=${record.filename}&v=${record.v}`) } }) ], }, { title: '大小', dataIndex: 'size', align: 'center', render: (col, record, index) => `${Math.round(record.size / 1024)}KB` }, { title: '上传日期', dataIndex: 'createdate', align: 'center', render: (col, record, index) => new Date(record.createdate).format('yyyy-MM-dd HH:mm'), }, ] // isloading = false return CAT_UI.Table({ columns: col_attrs, data: attrs[flowid], loading: !!!attrs[flowid], border: true, size: 'small', pagination: false, }) } CAT_UI.createPanel({ min: true, onMin: (min) => { }, point: { x: 0, y: 50 }, header: { title: () => { [data, setData] = CAT_UI.useState([]) return CAT_UI.Space( [ CAT_UI.Icon.ScriptCat({ style: { width: "24px", verticalAlign: "middle" }, draggable: "false", }) ], { style: { marginLeft: "0px" } } ) }, style: { background: '#e5e5ff' }, }, render: () => { [selectedRowKeys, setSelectedRowKeys] = CAT_UI.useState([]) let filterDropdownFun = ({ filterKeys, setFilterKeys, confirm }) => { return ( CAT_UI.el('div', {}, CAT_UI.Input.Search({ value: filterKeys[0] || '', searchButton: true, onChange: (value) => { setFilterKeys(value ? [value] : []); }, onSearch: () => { confirm() } })) ) } let col_affairs = [ // { title: 'ID', dataIndex: 'objectId', width: 50, align: 'center', ellipsis: true }, { title: '标题', dataIndex: 'subject', ellipsis: true, filterIcon: CAT_UI.Icon.IconSearch(), filterDropdown: filterDropdownFun, onFilter: (value, row) => new RegExp(value).test(row.subject), }, { title: '发起人', dataIndex: 'senderName', width: 100, align: 'center', ellipsis: true, filterIcon: CAT_UI.Icon.IconSearch(), filterDropdown: filterDropdownFun, onFilter: (value, row) => new RegExp(value).test(row.senderName), }, { title: '发起日期', dataIndex: 'createDate', width: 170, align: 'center', ellipsis: true, render: (col, record, index) => new Date(record.createDate).format('yyyy-MM-dd HH:mm'), }, { title: '操作', align: 'center', width: 110, render: (col, record, index) => CAT_UI.Space([ CAT_UI.Button(null, { icon: CAT_UI.Icon.IconLink(), // 打开流程 onClick: () => window.open(`http://oa.mengtiandairy.com:7070/seeyon/collaboration/collaboration.do?method=summary&openFrom=listPending&affairId=${record.id}`), size: 'small' }), CAT_UI.Button(null, { icon: CAT_UI.Icon.IconList(), // 查看审批进度 onClick: () => seeyouUtils.showDetailLogDialog(record.objectId), size: 'small' }), CAT_UI.Button(null, { icon: CAT_UI.Icon.IconBranch(), // 查看审批意见 onClick: () => { let comments = seeyouUtils.findsSummaryComments(record.objectId, record.id) console.log(comments) CAT_UI.Modal.info({ title: record.subject, visible: true, focusLock: false, style: { width: 1400 }, content: CAT_UI.Table({ columns: [ { title: '节点', dataIndex: 'postName', width: 150, align: 'center' }, { title: '审批人', dataIndex: 'createName', width: 150, align: 'center' }, { title: '审批状态', width: 100, align: 'center', render: (col, record, index) => [record.extAtt1I18n, record.extAtt2I18n, record.extAtt3I18n].join('') }, { title: '处理日期', dataIndex: 'createDate', width: 200, align: 'center' }, { title: '审批意见', dataIndex: 'escapedContent', render: (col, record, index) => record.escapedContent.replace(/\/g, '\n') }, ], data: comments.commentList, border: true, pagination: false }) }) }, size: 'small' }) ], { size: 0, align: 'center' }), }, { title: '付款方', dataIndex: 'payer', width: 100, ellipsis: true, editable: true, filterIcon: CAT_UI.Icon.IconSearch(), filterDropdown: filterDropdownFun, onFilter: (value, row) => new RegExp(value).test(row.payer), }, { title: '收款账户', dataIndex: 'supplyName', width: 200, ellipsis: true, editable: true, filterIcon: CAT_UI.Icon.IconSearch(), filterDropdown: filterDropdownFun, onFilter: (value, row) => new RegExp(value).test(row.supplyName), }, { title: '应付金额', dataIndex: 'accountPayable', width: 120, align: 'right', ellipsis: true, editable: true, }, { title: '已付金额', dataIndex: 'paidAmount', width: 120, align: 'right', ellipsis: true, editable: true, }, { title: '未付金额', width: 120, align: 'right', ellipsis: true, render: (col, record, index) => record.accountPayable - record.paidAmount, }, { title: '核销凭证', dataIndex: 'financeId', width: 200, ellipsis: false, editable: true, }, { title: '银行账号', dataIndex: 'account', width: 150, ellipsis: true, editable: true, }, { title: '开户行', dataIndex: 'depositBank', width: 100, ellipsis: true, editable: true, }, // { // title: '状态', dataIndex: 'state', width: 100, align: 'center', // render: (col, record, index) => { // let flowid = record.objectId // if (!(flowid in states)) // states[flowid] = seeyouUtils.state(flowid).value // record.state = states[flowid] // return states[flowid] // } // } ] let loadTableFun = async () => { tbData = await loopUserAffairs(config.data.userId, config.data.type) pagination.total = tbData.length let { current, pageSize } = pagination setData(tbData.slice((current - 1) * pageSize, current * pageSize)) } if (!init) { loadTableFun() init = true } return CAT_UI.Space( [ CAT_UI.Space([ CAT_UI.Select( Object.entries(config.userIds).map((v) => CAT_UI.Select.Option(v[0], { value: v[1] })), { addBefore: '账号', autoWidth: { minWidth: 200 }, triggerProps: { autoAlignPopupWidth: false }, onChange: (val) => { config.data.userId = val loadTableFun() }, defaultValue: config.data.userId } ), CAT_UI.Select( Object.entries(config.types).map((v) => CAT_UI.Select.Option(v[0], { value: v[1] })), { addBefore: '类型', autoWidth: { minWidth: 200 }, triggerProps: { autoAlignPopupWidth: false }, onChange: (val) => { config.data.type = val loadTableFun() }, defaultValue: config.data.type, } ), // 功能区 CAT_UI.Button('刷新列表', { icon: CAT_UI.Icon.IconSync(), shape: 'round', onClick: (e) => loadTableFun() }), CAT_UI.Button('转发协同', { icon: CAT_UI.Icon.IconCopy(), shape: 'round', onClick: (e) => seeyouUtils.transmitColById(currentSelectedRows) }), // 配置区 CAT_UI.moudles.Tooltip.render({ content: '是否按分页展示协同列表', children: CAT_UI.moudles.Switch.render({ defaultChecked: config.data.pageable, checkedText: '分页', uncheckedText: '单页', onChange: (val) => { config.data.pageable = val if (!config.data.pageable) setData([...tbData]) } }) }), CAT_UI.moudles.Tooltip.render({ content: '是否同步到seatable数据库', children: CAT_UI.moudles.Switch.render({ defaultChecked: config.seatable.asycn, checkedText: '同步', uncheckedText: '离线', onChange: (val) => { config.seatable.asycn = val } }) }), CAT_UI.moudles.Tooltip.render({ content: '是否遍历请求流程表单数据', children: CAT_UI.moudles.Switch.render({ defaultChecked: config.seatable.skip, checkedText: '概要', uncheckedText: '明细', onChange: (val) => { config.seatable.skip = val } }) }), CAT_UI.Button('保存配置', { icon: CAT_UI.Icon.IconSave(), shape: 'round', onClick: (e) => { GM_setValue('config', JSON.stringify(config)) CAT_UI.Message.success('已保存配置', { duration: 800 }) } }), ], { size: 'medium' }), CAT_UI.Table({ columns: col_affairs, data: data, loading: isloading, border: true, size: 'middle', rowKey: 'objectId', rowSelection: { selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { setSelectedRowKeys(selectedRowKeys) currentSelectedRows = [...selectedRows] }, type: 'checkbox', checkAll: true, }, expandedRowRender: expandedRow_attachments, onExpand: (record, expanded) => { let flowid = record['objectId'] if (!(flowid in attrs)) attrs[flowid] = seeyouUtils.attachments(flowid, '0') }, pagination: config.data.pageable ? pagination : false, fixedHeader: false, scroll: { y: window.screen.availHeight - 340 }, summary: (currentData) => { var sumdata = { accountPayable: currentData.reduce((prev, next) => prev + next.accountPayable, 0), paidAmount: currentData.reduce((prev, next) => prev + next.paidAmount, 0) } var s = { 'class': 'arco-table-td' } return CAT_UI.el('tr', {}, CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, '合计'), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', { ...s, style: { 'text-align': 'right' } }, (sumdata.accountPayable).toFixed(2)), CAT_UI.el('td', { ...s, style: { 'text-align': 'right' } }, (sumdata.paidAmount).toFixed(2)), CAT_UI.el('td', { ...s, style: { 'text-align': 'right' } }, (sumdata.accountPayable - sumdata.paidAmount).toFixed(2)), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), CAT_UI.el('td', s, ''), ) }, onChange: (tbconfig) => { let { current, pageSize } = tbconfig pagination.current = current pagination.pageSize = pageSize setData(tbData.slice((current - 1) * pageSize, current * pageSize)) } }), ], { direction: 'vertical' }) }, }) } // 流程面板 async function initFlowPanel(x, y) { let Form = CAT_UI.moudles.Form let rowpre let row, setRow let summaryId = unsafeWindow.summaryId let table_name = '流程' let init = false const seatable_base = new Base(config.seatable) await seatable_base.auth() CAT_UI.createPanel({ min: utils.getValue('ismin'), point: { x: x, y: y }, header: { title: () => { [row, setRow] = CAT_UI.useState({}) return CAT_UI.Space( [ CAT_UI.Icon.ScriptCat({ style: { width: "24px", verticalAlign: "middle" }, draggable: "false", }), ], { style: { marginLeft: "0px" } } ) }, style: { borderBottom: "1px solid var(--color-neutral-3)", // width: '500px' }, }, render: () => { formRef = CAT_UI.useRef({}) let fun = async () => { let rows = await seatable_base.queryAsync(`select * from ${table_name} where ID='${summaryId}'`) rowpre = { ...rows[0] } setRow(rows[0]) console.log('[OA] success load current flow data') } if (!init) { fun() init = true } let fieldChange = (val, e) => { setRow({ ...row, [e.target.name]: val }) } let fieldPressEnter = (e) => { // console.log(e.target) let key = e.target.name if (/金额/.test(key)) { let val = e.target.value if (typeof (val) == 'string') setRow({ ...row, [key]: parseFloat(eval(val.replace(/,/g, ''))) }) else setRow({ ...row, [key]: eval(val) }) } } return CAT_UI.Space([ Form.render({ style: { width: '350px' }, children: [ Form.Item.render({ label: 'ID', children: [ CAT_UI.Input({ value: row['ID'], name: 'ID', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '标题', children: [ CAT_UI.Input({ value: row['标题'], name: '标题', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '付款方', children: [ CAT_UI.Input({ value: row['付款方'], name: '付款方', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '收款账户', children: [ CAT_UI.Input({ value: row['收款账户'], name: '收款账户', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '核销凭证', children: [ CAT_UI.Input({ value: row['核销凭证'], name: '核销凭证', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '发起人', children: [ CAT_UI.Input({ value: row['发起人'], name: '发起人', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '申请金额', children: [ CAT_UI.Input({ value: row['申请金额'], name: '申请金额', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '应付金额', children: [ CAT_UI.Input({ value: row['应付金额'], name: '应付金额', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '已付金额', children: [ CAT_UI.Input({ value: row['已付金额'], name: '已付金额', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '未付金额', children: [ CAT_UI.Input({ value: Math.round((row['应付金额'] - row['已付金额']) * 100) / 100 })] }), Form.Item.render({ label: '银行账号', children: [ CAT_UI.Input({ value: row['银行账号'], name: '银行账号', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), Form.Item.render({ label: '开户行', children: [ CAT_UI.Input({ value: row['开户行'], name: '开户行', onChange: fieldChange, onPressEnter: fieldPressEnter })] }), ] }), CAT_UI.Space([ CAT_UI.Button('修改', { type: 'primary', onClick: () => { console.log(rowpre) let row_update_simplify = {} Object.entries(row).forEach(([k, v], i) => { if (rowpre[k] != v) row_update_simplify[k] = v }) if (Object.keys(row_update_simplify).length > 0) { seatable_base.updateRow(table_name, rowpre['_id'], row_update_simplify) CAT_UI.Message.success('修改完毕', { duration: 800 }) setTimeout(() => fun(), 500) rowpre = { ...row } } } }), CAT_UI.Button('取消', { type: 'secondary', onClick: () => { CAT_UI.Message.warning('取消修改', { duration: 800 }) setRow({ ...rowpre }) } }) ], { style: { display: 'flex', 'justify-content': 'flex-end' } }) ], { direction: 'vertical' }) } }) } if (/collaboration\/collaboration\.do\?method=summary/.test(location.href)) initFlowPanel($('#dealAreaThisRihgt').length > 0 ? 1150 : 1500, 150) else if (!(/seeyon\/common\/print\/(captPrintForm|print).jsp/.test(location.href))) initTable()