diff --git a/src/so/so/pub/pubrule/SObatchcodeBeforeEdit.js b/src/so/so/pub/pubrule/SObatchcodeBeforeEdit.js index 59cc2f08..f92b0754 100644 --- a/src/so/so/pub/pubrule/SObatchcodeBeforeEdit.js +++ b/src/so/so/pub/pubrule/SObatchcodeBeforeEdit.js @@ -1,10 +1,9 @@ -/*IGzbrQ6E+geanNSkta9fbTIiebkpHcYY5/0zqgWXSZE=*/ /* * @Author: wangceb * @PageInfo: 销售管理批次号参照编辑前事件 * @Date: 2018-08-15 20:44:14 - * @Last Modified by: liangzhyf - * @Last Modified time: 2021-03-02 15:51:20 + * @Last Modified by: liulux + * @Last Modified time: 2022-11-23 23:21:51 */ import { ajax, base } from 'nc-lightapp-front'; @@ -39,6 +38,24 @@ function SObatchcodeBeforeEdit(index, pk_org, cmaterialvid, data) { return false; } -export { SObatchcodeBeforeEdit }; +function SObatchcodeMultiBeforeEdit(map) { + // 查询物料是否批次管理 + return new Promise(function(resolve) { + let querydata = { + map:map + }; + ajax({ + url: '/nccloud/so/pub/batchcodeMultibefore.do', + data: querydata, + success: res => { + if (res.data) { + resolve(res.data); + } else { + resolve(false); + } + } + }); + }); +} -/*IGzbrQ6E+geanNSkta9fbTIiebkpHcYY5/0zqgWXSZE=*/ \ No newline at end of file +export { SObatchcodeBeforeEdit,SObatchcodeMultiBeforeEdit }; diff --git a/src/so/so/pub/pubrule/addMenuUtil.js b/src/so/so/pub/pubrule/addMenuUtil.js index 6c5eef97..6cf3d2bf 100644 --- a/src/so/so/pub/pubrule/addMenuUtil.js +++ b/src/so/so/pub/pubrule/addMenuUtil.js @@ -1,4 +1,3 @@ -/*11clYOLdEiy4eMwuItHv+04mARsYzhU2wuhooa92RoA=*/ /* * @Author: wangceb * @PageInfo: 页面功能描述 @@ -26,5 +25,3 @@ export function refBillQueryCache(refBillQueryData, dataSource, cacheKey) { } }); } - -/*11clYOLdEiy4eMwuItHv+04mARsYzhU2wuhooa92RoA=*/ \ No newline at end of file diff --git a/src/so/so/pub/pubrule/bodyrowVbatchcodeBeforeEdit.js b/src/so/so/pub/pubrule/bodyrowVbatchcodeBeforeEdit.js new file mode 100644 index 00000000..1fba8cc6 --- /dev/null +++ b/src/so/so/pub/pubrule/bodyrowVbatchcodeBeforeEdit.js @@ -0,0 +1,30 @@ +/* + * @Author: wangceb + * @PageInfo: 销售管理批次号参照编辑前事件 + * @Date: 2018-08-15 20:44:14 + * @Last Modified by: liangzhyf + * @Last Modified time: 2021-03-02 15:51:20 + */ +import { ajax } from 'nc-lightapp-front'; + +function bodyrowVbatchcodeBeforeEdit(grid) { + return new Promise(function(resolve, reject) { + ajax({ + url: '/nccloud/so/pub/bodyrowbatchcodebefore.do', + data: grid, + success: res => { + if (res.data) { + let isedit = res.data; + if (isedit === false) { + resolve(false); + } + resolve(res.data); + } else { + resolve(false); + } + } + }); + }); +} + +export { bodyrowVbatchcodeBeforeEdit }; diff --git a/src/so/so/pub/pubrule/editUtil.js b/src/so/so/pub/pubrule/editUtil.js index c067c02c..86194f22 100644 --- a/src/so/so/pub/pubrule/editUtil.js +++ b/src/so/so/pub/pubrule/editUtil.js @@ -1,4 +1,3 @@ -/*TmsLFMYUeJL720Nh4y/WUD8sLe8zLJNWgl+WdKFFqiM=*/ /** * 主组织主动触发编辑后事件 * @param {*} props @@ -36,5 +35,3 @@ function edit(props, type, areacode, key, value, changedrows, index, afterEvent) } export { mainOrgEdit, editForm }; - -/*TmsLFMYUeJL720Nh4y/WUD8sLe8zLJNWgl+WdKFFqiM=*/ \ No newline at end of file diff --git a/src/so/so/pub/pubrule/headTotalCalRule.js b/src/so/so/pub/pubrule/headTotalCalRule.js index e3e886f5..554420c6 100644 --- a/src/so/so/pub/pubrule/headTotalCalRule.js +++ b/src/so/so/pub/pubrule/headTotalCalRule.js @@ -1,4 +1,3 @@ -/*170hMnCqNSHHX84AUgVf1stZOxJLjD3c3eco9+PidT0=*/ /* * @Author: zhangjyp * @PageInfo: 计算表头合计 @@ -48,5 +47,3 @@ export default function calHeadTotal(props, pageId, formId, tableId, keymaps) { }); } } - -/*170hMnCqNSHHX84AUgVf1stZOxJLjD3c3eco9+PidT0=*/ \ No newline at end of file diff --git a/src/so/so/pub/pubrule/isFixedRateBeforeEvent.js b/src/so/so/pub/pubrule/isFixedRateBeforeEvent.js index fcc6b2a2..c7d95f07 100644 --- a/src/so/so/pub/pubrule/isFixedRateBeforeEvent.js +++ b/src/so/so/pub/pubrule/isFixedRateBeforeEvent.js @@ -1,4 +1,3 @@ -/*rJyT6t0/hN/nPeLTCKsosG8bXS+pKR6mqrO0qUy6c0U=*/ /* * @Author: wangceb * @PageInfo: 判断是否固定换算率 @@ -39,5 +38,3 @@ export default function(props, constance) { }); }); } - -/*rJyT6t0/hN/nPeLTCKsosG8bXS+pKR6mqrO0qUy6c0U=*/ \ No newline at end of file diff --git a/src/so/so/pub/pubrule/vbillcodeBeforeEvent.js b/src/so/so/pub/pubrule/vbillcodeBeforeEvent.js index 85d1521d..f87f50a5 100644 --- a/src/so/so/pub/pubrule/vbillcodeBeforeEvent.js +++ b/src/so/so/pub/pubrule/vbillcodeBeforeEvent.js @@ -1,4 +1,3 @@ -/*rV0bQibesG0UGdyoLFMSM7410XISRh6ukPKiIb9FaMU=*/ /** * 编辑前处理,需要物料 * 这类方法必须有返回值,返回true为可编辑,false为不可编辑 @@ -48,5 +47,3 @@ export default function(props, constance) { } }); } - -/*rV0bQibesG0UGdyoLFMSM7410XISRh6ukPKiIb9FaMU=*/ \ No newline at end of file diff --git a/src/so/so/pub/pubrule/vfreeBeforeEvent.js b/src/so/so/pub/pubrule/vfreeBeforeEvent.js index c132ebf4..e0ad17ae 100644 --- a/src/so/so/pub/pubrule/vfreeBeforeEvent.js +++ b/src/so/so/pub/pubrule/vfreeBeforeEvent.js @@ -1,4 +1,3 @@ -/*VN6N61ClU/zPuqLSyAXrv36kgZ5RYa4FfXkmFt0zCLI=*/ /** * 物料自由辅助属性编辑前处理,需要物料的固定辅助属性库存状态启用 * 这类方法必须有返回值,返回true为可编辑,false为不可编辑 @@ -54,5 +53,3 @@ export default function (props, constance) { } }); } - -/*VN6N61ClU/zPuqLSyAXrv36kgZ5RYa4FfXkmFt0zCLI=*/ \ No newline at end of file diff --git a/src/so/so/pub/queryarea/queryAreaInit.js b/src/so/so/pub/queryarea/queryAreaInit.js index 925ad296..f1bd31a7 100644 --- a/src/so/so/pub/queryarea/queryAreaInit.js +++ b/src/so/so/pub/queryarea/queryAreaInit.js @@ -1,4 +1,3 @@ -/*9s06cI9qriZwm9mh0Mrs2v5n+PTUxsbrUhg0bAz4Pfc=*/ /* * @Author: wangceb * @PageInfo: 页面功能描述 @@ -107,5 +106,3 @@ function renderCompleteEvent(moduleId, orgfield, callback, ctrantypeid) { } export { renderCompleteEvent }; - -/*9s06cI9qriZwm9mh0Mrs2v5n+PTUxsbrUhg0bAz4Pfc=*/ \ No newline at end of file diff --git a/src/so/so/pub/tool/BillCardTool.js b/src/so/so/pub/tool/BillCardTool.js new file mode 100644 index 00000000..3a49522f --- /dev/null +++ b/src/so/so/pub/tool/BillCardTool.js @@ -0,0 +1,34 @@ +/* +* @Author: wangceb +* @PageInfo: 销售js工具类 +* @Date: 2018-04-04 13:50:36 + * @Last Modified by: zhangjyp + * @Last Modified time: 2018-07-17 13:54:15 +*/ + +function createMasterChildDataForEditTable(props, pageid, head_code, body_code) { + let saveData = { + pageid: pageid, + head: {}, + body: {} + }; + let metaObj = props.meta.getMeta(); + if (metaObj[head_code] && metaObj[head_code].moduletype && metaObj[head_code].moduletype === 'form') { + saveData.head[head_code] = props.form.getAllFormValue(head_code); + saveData.head[head_code].areacode = head_code; + } + if (metaObj[body_code] && metaObj[body_code].moduletype && metaObj[body_code].moduletype === 'table') { + saveData.body[body_code] = props.editTable.getAllData(body_code); + saveData.body[body_code].areacode = body_code; // 设置伪劣 + let index = 0; + saveData.body[body_code].rows.forEach((row) => { + if (row.status != '3') { + row.values.pseudocolumn = { value: index.toString() }; + index++; + } + }); + } + return saveData; +} + +export { createMasterChildDataForEditTable }; diff --git a/src/so/so/pub/tool/SearchTool.js b/src/so/so/pub/tool/SearchTool.js index c9e09c8c..fde83d29 100644 --- a/src/so/so/pub/tool/SearchTool.js +++ b/src/so/so/pub/tool/SearchTool.js @@ -1,4 +1,3 @@ -/*Cb8MTr5qR67cvq+nos7DlH+FxOS12KSQ9wA1NqqlgmU=*/ /* * @Author: wangceb * @PageInfo: 查询区常用工具 @@ -19,5 +18,3 @@ function getSearchValByField(props, searchId, field) { } export { getSearchValByField }; - -/*Cb8MTr5qR67cvq+nos7DlH+FxOS12KSQ9wA1NqqlgmU=*/ \ No newline at end of file diff --git a/src/so/so/pub/tool/TransferTool.js b/src/so/so/pub/tool/TransferTool.js index 5a88b1a5..2720f133 100644 --- a/src/so/so/pub/tool/TransferTool.js +++ b/src/so/so/pub/tool/TransferTool.js @@ -1,4 +1,3 @@ -/*XqIkjfsfunKy+hfouHD5cxN+YW8cQkFSgYG38hCXxC0=*/ /* * @Author: wangceb * @PageInfo: 转单界面工具类 @@ -62,5 +61,3 @@ function formatNumber(value) { } return ret; } - -/*XqIkjfsfunKy+hfouHD5cxN+YW8cQkFSgYG38hCXxC0=*/ \ No newline at end of file diff --git a/src/so/so/pub/tool/TrimZeroUtil.js b/src/so/so/pub/tool/TrimZeroUtil.js index 018c67c2..f126b4de 100644 --- a/src/so/so/pub/tool/TrimZeroUtil.js +++ b/src/so/so/pub/tool/TrimZeroUtil.js @@ -1,4 +1,3 @@ -/*Z8rANEvCYYFtqTbCYDvR5Cn++w1AZR0Ijqm7jNDiTPU=*/ /* * @Author: zhangjyp * @PageInfo: 数值取精度,例如:2.3,精度是1 @@ -16,5 +15,3 @@ export default function trimZero(data) { return length - 1 - start; } - -/*Z8rANEvCYYFtqTbCYDvR5Cn++w1AZR0Ijqm7jNDiTPU=*/ \ No newline at end of file diff --git a/src/so/so/pub/tool/cfgmatchTool.js b/src/so/so/pub/tool/cfgmatchTool.js new file mode 100644 index 00000000..b5a0ae54 --- /dev/null +++ b/src/so/so/pub/tool/cfgmatchTool.js @@ -0,0 +1,18 @@ +/* +* @Author: chaiwx +* @PageInfo: 模型选配js工具类 +* @Date: 2018-04-04 13:50:36 + * @Last Modified by: liulux + * @Last Modified time: 2023-08-25 10:58:07 +*/ + +function clearCmffileid(billcard, moduleId) { + if (billcard.body) { + for (let i = 0; i < billcard.body[moduleId].rows.length; i++) { + const row = billcard.body[moduleId].rows[i]; + Reflect.deleteProperty(row.values, 'cmffileid'); + } + } +} + +export { clearCmffileid }; diff --git a/src/so/so/pub/tool/returntool/index.js b/src/so/so/pub/tool/returntool/index.js new file mode 100644 index 00000000..703bb941 --- /dev/null +++ b/src/so/so/pub/tool/returntool/index.js @@ -0,0 +1,80 @@ +/* + * @Author: wangceb + * @PageInfo: 退货节点工具类 + * @Date: 2019-05-15 15:02:06 + * @Last Modified by: cuijun + * @Last Modified time: 2019-07-17 11:08:35 + */ +import { showErrorInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil.js'; +import { getMultiLang } from 'nc-lightapp-front'; + +/** + * 处理消息提示的多语问题,定义的提示多语容器(ES6语法支持面向对象类) + */ +class LangContainer { + constructor() { + this.lang = null; + this.inlt = null; + // 初始化提示多语信息 + getMultiLang({ + moduleId: '4006pubmassage', + domainName: 'so', + callback: this.init.bind(this), + needInlt: true + }); + } + + init(lang, status, inlt) { + if (status) { + this.lang = lang; + this.inlt = inlt; + } + } + + getLangByResId(resid, param) { + let str = resid; + if (param) { + str = this.inlt.get(resid, param); + return str ? str : resid; + } else { + // 如果还没有加载回来,则返回空,避免页面显示多语字符串 + if (this.lang) { + str = this.lang[resid]; + return str ? str : resid; + } else { + return resid; + } + } + } +} + +/** + * 实例化多语容器 + */ +const lang = new LangContainer(); +/** + * 组织节点校验 + * 组织节点只能维护当前节点有权限组织的数据! + * @param {*} rows + * @param {*} nodetype + */ +export function isCanEdit(rows, nodetype, pk_org_field) { + let ret = true; + if (nodetype === 'group') { + return ret; + } + + if (!pk_org_field) { + pk_org_field = 'pk_org'; + } + rows.forEach((row) => { + if (row.values.pk_group.value === row.values[pk_org_field].value) { + ret = false; + return; + } + }); + if (!ret) { + showErrorInfo(lang.getLangByResId('4006PUBMASSAGE-000000')); //组织节点只能维护当前节点有权限组织的数据! + } + return ret; +} diff --git a/src/so/so/pub/util/batchCodeUtil.js b/src/so/so/pub/util/batchCodeUtil.js new file mode 100644 index 00000000..e3091fc3 --- /dev/null +++ b/src/so/so/pub/util/batchCodeUtil.js @@ -0,0 +1,276 @@ +import { TOBillType } from '../enum'; +import { deepClone } from 'nc-lightapp-front'; + +// ---------------------------------批次号编辑后处理------------------------------------------------ +function processBatchCodeValue(props, moduleId, rows, clearfields) { + if (!rows) { + return; + } + + if (rows.length == 0) { + return; + } + + // add by chaiwx,row.values中存在一个refpk='xxxx'的字段,暂时无用,但会导致后台报错。这里清空一下。 + rows.forEach((row) => { + if (row.hasOwnProperty('values')) { + row.values.refpk = {}; + } + }); + + // 构建批次号后台结构 + let grid = { + model: { + rows: rows + } + }; + return { + scm_vbatchcode: JSON.stringify(grid), + scm_clearfields: clearfields + }; +} + +function processBatchCodeAfterEdit(props, moduleId, record, index, rows, clearFields) { + if (!record && !rows) { + return; + } + let returnRows = rows[0] + ? rows[0].preStore ? rows[0].preStore : rows[0].usable ? rows[0].usable : rows[0].addBatch + : []; + let newRow = processBatchCodeReturnData(record, returnRows, clearFields); + if (newRow) { + let indexArray = [ index + '' ]; + //第一个元素更新,剩余的元素插入 + props.cardTable.updateDataByIndexs(moduleId, newRow[0]); + if (newRow.length > 0) { + //从第二个元素开始循环,构建数组用来新增 + let insertRows = []; + for (let i = 1; i < newRow.length; i++) { + let insertRow = { index: index + i, data: newRow[i] }; + insertRows.push(insertRow); + indexArray.push(index + i + ''); + } + props.cardTable.insertDataByIndexs(moduleId, insertRows); + } + return indexArray; + } +} + +/** + * 处理批次号返回值 + * @param {*} oldRow + * @param {*} newRows + * @param {*} clearFields + */ +function processBatchCodeReturnData(oldRow, newRows, clearFields) { + if (!oldRow || !newRows || !newRows[0]) { + return oldRow; + } + let realRows = []; + if (newRows.length == 1) { + realRows.push(processCurRow(oldRow, newRows[0])); + } else { + realRows.push(processCurRow(oldRow, newRows[0])); + for (let i = 1; i < newRows.length; i++) { + let tempRow = deepClone(oldRow); + tempRow.status = 2; + // 清空行号 + clearRowFields(tempRow, clearFields); + realRows.push(processCurRow(tempRow, newRows[i])); + } + } + return realRows; +} + +/** + * 清空复制的行的相关字段 + * @param {*} row + * @param {*} clearFields + */ +function clearRowFields(row, clearFields) { + row.values['crowno'] = { value: null, display: null }; + if (clearFields) { + clearFields.forEach((field) => { + let scale = row.values[field].scale; + row.values[field] = { value: null, scale: scale, display: null }; + }); + } +} + +/** + * 处理单行数据 + * @param {*} oldRow + * @param {*} newRow + */ +function processCurRow(oldRow, newRow) { + if (!oldRow || !newRow) { + return [ oldRow ]; + } + oldRow.values['pk_batchcode'] = newRow.values['pk_batchcode']; + //单据上批次号是参照类型,参照框中是字符串类型,参照类型不许要有display才能显示 + oldRow.values['vbatchcode'] = newRow.values['vbatchcode'] + ? { value: newRow.values['vbatchcode'].value, display: newRow.values['vbatchcode'].value } + : null; + return oldRow; +} + +//----------------------------------批次号编辑前处理--------------------------------------------- +/** + * 处理批次号字段 + * @param {*} props + * @param {*} moduleId 区域ID + * @param {*} key item字段 + * @param {*} headData 当前行数据 + * @param {*} billtype 单据类型 + */ +function processBatchCodeItem(props, moduleId, key, headData, billtype) { + // 预处理数据 + let headRows = processBatchCodeHeadData(headData, billtype); + // 渲染对应的批次号 + let meta = props.meta.getMeta(); + let item = meta[moduleId].items.find((item) => item.attrcode == key); + let item2 = meta['childform2'].items.find((item) => item.attrcode == key); + item.itemtype = 'refer'; + item.refcode = 'ic/refer/onhand/onhandRef/index.js'; + item.headRows = headRows; + item.appcode = '400900800'; + item.headTemplateCode = '400900800_batchcodeH'; + item.bodyTemplateCode = '400900800_batchcodeB'; + item.undealNumCode = 'onhandshouldnum'; + item.thisNumCode = 'onhandcurrentnum'; + item.isSatisfyCode = 'fulfiltype'; + props.renderItem(meta[moduleId].moduletype, moduleId, key, null); + item2.itemtype = 'refer'; + item2.refcode = 'ic/refer/onhand/onhandRef/index.js'; + item2.headRows = headRows; + item2.appcode = '400900800'; + item2.headTemplateCode = '400900800_batchcodeH'; + item2.bodyTemplateCode = '400900800_batchcodeB'; + item2.undealNumCode = 'onhandshouldnum'; + item2.thisNumCode = 'onhandcurrentnum'; + item2.isSatisfyCode = 'fulfiltype'; + props.renderItem(meta['childform2'].moduletype, 'childform2', key, null); + props.meta.setMeta(meta); +} + +/** + * 处理批次号表头数据 + * @param {*} headData + * @param {*} billtype + */ +function processBatchCodeHeadData(headData, billtype) { + let row = { values: {} }; + Object.keys(BATCHCODEHEAD).forEach((key) => { + let field = BATCHCODEHEAD[key]; + if (field == BATCHCODEHEAD.pk_group) { + //集团 + } else if (field == BATCHCODEHEAD.cwarehouseid) { + //仓库 + setWareHouseId(row, headData, field, billtype); + } else if (field == BATCHCODEHEAD.pk_org) { + //组织 + setPkOrg(row, headData, field, billtype); + } else if (field == BATCHCODEHEAD.cmaterialvid) { + //物料版本 + row.values[field] = headData.values['cinventoryvid']; + } else if (field == BATCHCODEHEAD.cmaterialoid) { + //物料 + row.values[field] = headData.values['cinventoryid']; + } else if (field == BATCHCODEHEAD.onhandshouldassnum) { + row.values[field] = headData.values['nastnum']; + } else if (field == BATCHCODEHEAD.onhandshouldnum) { + row.values[field] = headData.values['nnum']; + } else if (field == BATCHCODEHEAD.cvmivenderid) { + //寄存供应商 + setVmivenderId(row, headData, field, billtype); + } else { + row.values[field] = headData.values[field]; + } + }); + return { rows: [ row ] }; +} + +/** + * 设置组织 + * @param {*} row + * @param {*} headData + * @param {*} field + * @param {*} billtype + */ +function setPkOrg(row, headData, field, billtype) { + if (TOBillType.TransIn === billtype) { + //主组织 + row.values[field] = headData.values['pk_org']; + } else if (TOBillType.TransOrder === billtype) { + //出货库存组织 + row.values[field] = headData.values['ctoutstockorgid']; + } else if (TOBillType.Allot === billtype) { + //主组织 + row.values[field] = headData.values['pk_org']; + } +} +/** + * 设置仓库 + * @param {*} row + * @param {*} headData + * @param {*} field + * @param {*} billtype + */ +function setWareHouseId(row, headData, field, billtype) { + if (TOBillType.TransIn === billtype) { + //调入仓库 + row.values[field] = headData.values['cinstordocid']; + } else if (TOBillType.TransOrder === billtype) { + //出货仓库 + row.values[field] = headData.values['ctoutstordocid']; + } else if (TOBillType.Allot === billtype) { + //调出仓库 + row.values[field] = headData.values['coutstordocid']; + } +} +/** + * 设置寄存供应商 + * @param {*} row + * @param {*} headData + * @param {*} field + * @param {*} billtype + */ +function setVmivenderId(row, headData, field, billtype) { + if (TOBillType.TransOrder === billtype) { + row.values[field] = headData.values['cconsignvendorid']; + } +} + +const BATCHCODEHEAD = { + pk_group: 'pk_group', + cwarehouseid: 'cwarehouseid', + pk_org: 'pk_org', + cmaterialvid: 'cmaterialvid', + cmaterialoid: 'cmaterialoid', + onhandshouldassnum: 'onhandshouldassnum', + onhandshouldnum: 'onhandshouldnum', + cvmivenderid: 'cvmivenderid', + vbatchcode: 'vbatchcode', + pk_batchcode: 'pk_batchcode', + crowno: 'crowno', + cunitid: 'cunitid', + castunitid: 'castunitid', + vchangerate: 'vchangerate', + cvendorid: 'cvendorid', + cproductorid: 'cproductorid', + cprojectid: 'cprojectid', + casscustid: 'casscustid', + cffileid: 'cffileid', + vfree1: 'vfree1', + vfree2: 'vfree2', + vfree3: 'vfree3', + vfree4: 'vfree4', + vfree5: 'vfree5', + vfree6: 'vfree6', + vfree7: 'vfree7', + vfree8: 'vfree8', + vfree9: 'vfree9', + vfree10: 'vfree10' +}; + +export { processBatchCodeItem, processBatchCodeValue }; diff --git a/src/so/so/pub/util/compareUtil.js b/src/so/so/pub/util/compareUtil.js new file mode 100644 index 00000000..0cef1730 --- /dev/null +++ b/src/so/so/pub/util/compareUtil.js @@ -0,0 +1,21 @@ +/* + * @Author: xiahui + * @PageInfo: 差异操作 + * @Date: 2019-01-02 09:12:11 + * @Last Modified by: xiahui + * @Last Modified time: 2019-01-03 15:28:31 + */ + +/** + * 列表单行操作差异容错 + * @param {*} newData 差异返回的新数据 + * @param {*} oldValues 操作前的行数据 + * @param {*} config 差异操作参数 + */ +function listSingleTolerateForCompare(newData, oldValues, config) { + let { headAreaId } = config; + let newValues = newData.head[headAreaId].rows[0].values; + newData.head[headAreaId].rows[0].values = { ...oldValues, ...newValues }; +} + +export { listSingleTolerateForCompare }; diff --git a/src/so/so/pub/util/editUtil.js b/src/so/so/pub/util/editUtil.js new file mode 100644 index 00000000..86194f22 --- /dev/null +++ b/src/so/so/pub/util/editUtil.js @@ -0,0 +1,37 @@ +/** + * 主组织主动触发编辑后事件 + * @param {*} props + * @param {*} areacode 区域编码 + * @param {*} key 触发字段,默认为pk_org + * @param {*} value 触发的value {value:,display:} + * @param {*} afterEvent 自己的编辑后事件 + */ +function mainOrgEdit(props, areacode, key = 'pk_org', value, afterEvent) { + editForm(props, areacode, key, value, afterEvent); +} + +/** + * 编辑form表单 + * @param {*} props + * @param {*} areacode + * @param {*} key + * @param {*} value + * @param {*} afterEvent + */ +function editForm(props, areacode, key, value, afterEvent) { + edit(props, 'form', areacode, key, value, null, null, afterEvent); +} + +function edit(props, type, areacode, key, value, changedrows, index, afterEvent) { + props.handleRelationItems({ + type: type, //编辑的是表单值为'form', 编辑的是表格值为'table' + areaCode: areacode, //编辑区域的编码 + key: key, //编辑字段英文名称 + value: value, //编辑字段的新值 + changedrows: changedrows, // 若编辑的是表格,需要传该参数(编辑字段的旧值),表单不传 + index: index, //当前是第几行 : 从 0 开始,编辑表格时,需要传该参数,表单不传 + callback: afterEvent //请求成功的回调(业务组自己的编辑后事件) + }); +} + +export { mainOrgEdit, editForm }; diff --git a/src/so/so/pub/util/linkDataUtil.js b/src/so/so/pub/util/linkDataUtil.js new file mode 100644 index 00000000..e5f3736c --- /dev/null +++ b/src/so/so/pub/util/linkDataUtil.js @@ -0,0 +1,55 @@ +import { ajax, cacheTools } from 'nc-lightapp-front'; + +const LINK_KEY = 'tolinkkey'; + +/** + * 列表态联查处理 + * @param {*} props + * @param {*} config {areacode:区域编码,pagecode:页面编码,tabletype:表格类型(table/editTable),url:后台地址,deflinkquery:自定义处理逻辑} + */ +function listLinkQuery(props, config) { + let { deflinkquery, areacode, pagecode, tabletype = 'table', url } = config; + + // 1、获取link参数 + let linkkey = props.getUrlParam(LINK_KEY); + if (linkkey) { + let linkdata = cacheTools.get(linkkey); + // linkdata结构为:{linktype:'30',linkids:['','']} + if (linkdata) { + let linktype = linkdata.linktype; + let linkids = linkdata.linkids; + if (deflinkquery && deflinkquery.hasOwnProperty(linktype)) { + let deflinkqueryAction = deflinkquery[linktype]; + deflinkqueryAction(linkids); + } else { + ajax({ + url: url, + data: { + pageid: pagecode, + allpks: linkids + }, + success: (res) => { + let data = res.data; + if (data) { + if ('table' === tabletype) { + props.table.setAllTableData(areacode, res.data[areacode]); + } + if ('editTable' === tabletype) { + props.editTable.setTableData(areacode, res.data[areacode]); + } + } + } + }); + } + } + clear(props, linkkey); // 清除数据 + } +} + +function clear(props, linkkey) { + props.setUrlParam({ + [LINK_KEY]: null + }); + cacheTools.remove(linkkey); +} +export { listLinkQuery }; diff --git a/src/so/so/pub/util/numberUtil.js b/src/so/so/pub/util/numberUtil.js new file mode 100644 index 00000000..25927948 --- /dev/null +++ b/src/so/so/pub/util/numberUtil.js @@ -0,0 +1,17 @@ +/* + * @Author: chaiwx + * @PageInfo: 数值工具 + * @Date: 2019-01-03 14:24:39 + * @Last Modified by: chaiwx + * @Last Modified time: 2019-01-03 14:52:13 + */ + +/** + * 显示为千分位 + */ +function toThousandsPattern(num) { + num = num + ''; + return num.replace(/(?=(?!(\b))(\d{3})+$)/g, '$1,'); //使用正则替换,每隔三个数加一个',' +} + +export { toThousandsPattern }; diff --git a/src/so/so/pub/util/operateDataUtil.js b/src/so/so/pub/util/operateDataUtil.js index 3cecfbb8..1041437d 100644 --- a/src/so/so/pub/util/operateDataUtil.js +++ b/src/so/so/pub/util/operateDataUtil.js @@ -1,4 +1,3 @@ -/*dkS8HPbHFEj6+q7wB+z0gzTfR5UufDtXc/jwCRxg814=*/ /* * @Author: sunxxf * @PageInfo: 收回数据组装 @@ -39,5 +38,3 @@ function getPkTsDataIncludeBodyInCard(props, params) { } export { getPkTsDataIncludeBodyInCard }; - -/*dkS8HPbHFEj6+q7wB+z0gzTfR5UufDtXc/jwCRxg814=*/ \ No newline at end of file diff --git a/src/so/so/pub/util/referUtil.js b/src/so/so/pub/util/referUtil.js new file mode 100644 index 00000000..e320aacc --- /dev/null +++ b/src/so/so/pub/util/referUtil.js @@ -0,0 +1,226 @@ +/** + * 设置参照显示业务单元 + * @param {*} props + * @param {*} area 区域编码 + * @param {*} fields 参照字段 为空,认为区域内全参照字段 + * @param {*} isShow 显示还是隐藏 + * @returns meta + */ +function setReferMultiUnitShow(meta, area, fields = [], isShow = true) { + meta[area].items.map((item) => { + let fieldcode = item.attrcode; + if (fields.length > 0) { + if (fields.includes(fieldcode)) { + item.isShowUnit = isShow; + } + } else { + if (item.itemtype === 'refer') { + item.isShowUnit = isShow; + } + } + }); + return meta; +} + +/** + * 设置参照显示业务单元(按照单个Item) + * @param {*} item + * @param {*} fields + * @param {*} isShow + */ +function setReferMultiUnitShowByItem(item, fields = [], isShow = true) { + let fieldcode = item.attrcode; + if (fields.includes(fieldcode)) { + item.isShowUnit = isShow; + } +} + +/** + * 设置主组织权限-默认是表格型的,存货核算大部分都是成本域 + * @param {*} item + * @param {*} type + */ +function setRefMainOrgPermissonByItem(item, type) { + if (type && type === MAINORG_TYPE.TREE) { + item.queryCondition = () => { + return { TreeRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgRefFilter' }; + }; + } else { + item.queryCondition = () => { + return { GridRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgRefFilter' }; + }; + } +} + +/** + * 设置主组织权限-默认是表格型的,存货核算大部分都是成本域 + * @param {*} item + * @param {*} type + */ +function setRefMainOrgPermisson(meta, area, field, type) { + meta[area].items.map((item) => { + if (item.attrcode === field) { + if (type && type === MAINORG_TYPE.TREE) { + item.queryCondition = () => { + return { TreeRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgRefFilter' }; + }; + } else { + item.queryCondition = () => { + return { GridRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgRefFilter' }; + }; + } + } + }); + return meta; +} + +/** + * 设置主组织权限(VID字段) + * @param {*} item + */ +function setRefMainOrgVIDPermissonByItem(item, type) { + if (type && type === MAINORG_TYPE.TREE) { + item.queryCondition = () => { + return { TreeRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgVidRefFilter' }; + }; + } else { + item.queryCondition = () => { + return { GridRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgVidRefFilter' }; + }; + } +} + +/** + * 初始化业务单元多选 + * @param {*} meta meta + * @param {*} searchAreaID 区域id + * @param {*} fields 字段 + * @param {*} defPrefix 自定义项前缀 + * @param {*} freePrefix 自由辅助属性前缀 + */ +function initMultiSelect(meta, searchAreaID, fields, defPrefix, freePrefix) { + let searchItems = meta[searchAreaID].items; + if (!Array.isArray(fields)) { + fields = [ fields ]; + } + + if (!defPrefix) { + defPrefix = []; + } else if (!Array.isArray(defPrefix)) { + defPrefix = [ defPrefix ]; + } + + if (!freePrefix) { + freePrefix = []; + } else if (!Array.isArray(freePrefix)) { + freePrefix = [ freePrefix ]; + } + + searchItems.map((item) => { + if (fields.includes(item.attrcode)) { + item.isShowUnit = true; + } + for (let i = 0; i < freePrefix.length; i++) { + if (item.attrcode.indexOf(freePrefix[i]) == 0) { + item.isShowUnit = true; + } + } + for (let i = 0; i < defPrefix.length; i++) { + if (item.attrcode.indexOf(defPrefix[i]) == 0) { + item.isShowUnit = true; + } + } + }); +} + +/** + * 查询组织多选处理 + * @param {*} props + * @param {*} searchAreaID 查询区ID + * @param {*} orgField 组织字段 + * @param {*} relationFields 关联字段 + * @param {*} defPrefix 自定义项前缀 可空 + * @param {*} freePrefix 自由辅助属性前缀 可空 + */ +function orgMultiSelectHandler(props, searchAreaID, orgField, relationFields, defPrefix, freePrefix) { + let meta = props.meta.getMeta(); + let searchItems = meta[searchAreaID].items; + + if (!Array.isArray(relationFields)) { + relationFields = [ relationFields ]; + } + + if (!defPrefix) { + defPrefix = []; + } else if (!Array.isArray(defPrefix)) { + defPrefix = [ defPrefix ]; + } + + if (!freePrefix) { + freePrefix = []; + } else if (!Array.isArray(freePrefix)) { + freePrefix = [ freePrefix ]; + } + + //获取当前关联字段的值 + let fieldValue = props.search.getSearchValByField(searchAreaID, orgField); + //判断当前值是否为空 + if ( + fieldValue && + fieldValue.value && + fieldValue.value.firstvalue && + fieldValue.value.firstvalue.indexOf(',') == -1 + ) { + searchItems.map((item) => { + if (relationFields.includes(item.attrcode)) { + item.isShowUnit = false; + } + for (let i = 0; i < freePrefix.length; i++) { + if (item.attrcode.indexOf(freePrefix[i]) == 0) { + item.isShowUnit = false; + } + } + for (let i = 0; i < defPrefix.length; i++) { + if (item.attrcode.indexOf(defPrefix[i]) == 0) { + item.isShowUnit = false; + } + } + }); + } else { + searchItems.map((item) => { + if (relationFields.includes(item.attrcode)) { + item.isShowUnit = true; + } + for (let i = 0; i < freePrefix.length; i++) { + if (item.attrcode.indexOf(freePrefix[i]) == 0) { + item.isShowUnit = true; + } + } + for (let i = 0; i < defPrefix.length; i++) { + if (item.attrcode.indexOf(defPrefix[i]) == 0) { + item.isShowUnit = true; + } + } + }); + } + props.meta.setMeta(meta); +} + +/** + * 主组织格式类型:Grid or Tree + */ +const MAINORG_TYPE = { + GRID: 'grid', + TREE: 'tree' +}; + +export { + MAINORG_TYPE, + setReferMultiUnitShow, + setReferMultiUnitShowByItem, + setRefMainOrgPermisson, + setRefMainOrgPermissonByItem, + setRefMainOrgVIDPermissonByItem, + orgMultiSelectHandler, + initMultiSelect +}; diff --git a/src/so/so/pub/util/remoteBooleanRequest.js b/src/so/so/pub/util/remoteBooleanRequest.js new file mode 100644 index 00000000..6143a57c --- /dev/null +++ b/src/so/so/pub/util/remoteBooleanRequest.js @@ -0,0 +1,26 @@ +/* + * @Author: chaiwx + * @PageInfo: 同步ajax请求,返回值为true、false + * @Date: 2018-06-14 15:24:52 + * @Last Modified by: chaiwx + * @Last Modified time: 2018-09-12 15:54:23 + */ +import { ajax, toast } from 'nc-lightapp-front'; +export default function(url, data) { + return new Promise(function(resolve, reject) { + ajax({ + url: url, + data: data, + success: (res) => { + resolve(true); + }, + error: (error) => { + toast({ + color: 'warning', + content: error.message + }); + resolve(false); + } + }); + }); +} diff --git a/src/so/so/pub/util/thousandUtil.js b/src/so/so/pub/util/thousandUtil.js new file mode 100644 index 00000000..616b632a --- /dev/null +++ b/src/so/so/pub/util/thousandUtil.js @@ -0,0 +1,46 @@ +/** + * 输入数字将其显示为千分位显示 + * @param {} value + * @returns + */ +function MillenniumRepresentation(value) { + if (isNaN(value)) { + return 0; + } + var arr = new String(value).split('.'); + var negative = arr[0].startsWith('-'); + var list = !negative ? arr[0].split('').reverse() : arr[0].substring(1, arr[0].length).split('').reverse(); + for (var i = 0; i < list.length; i++) { + if (i % 4 == 3) { + list.splice(i, 0, ','); + } + } + return arr.length > 1 + ? !negative ? list.reverse().join('') + '.' + arr[1] : '-' + list.reverse().join('') + '.' + arr[1] + : !negative ? list.reverse().join('') : '-' + list.reverse().join(''); +} + +/** + * 获取千分位并截取两位小数 + * @param {*} value + * @returns + */ +function MillenniumRepresentationToFixed(value) { + if (isNaN(value)) { + return 0; + } + value = parseFloat(new String(value)).toFixed(2); + var arr = new String(value).split('.'); + var negative = arr[0].startsWith('-'); + var list = !negative ? arr[0].split('').reverse() : arr[0].substring(1, arr[0].length).split('').reverse(); + for (var i = 0; i < list.length; i++) { + if (i % 4 == 3) { + list.splice(i, 0, ','); + } + } + return arr.length > 1 + ? !negative ? list.reverse().join('') + '.' + arr[1] : '-' + list.reverse().join('') + '.' + arr[1] + : !negative ? list.reverse().join('') : '-' + list.reverse().join(''); +} + +export { MillenniumRepresentation, MillenniumRepresentationToFixed }; diff --git a/src/so/so/sobalance/card/btnClicks/addRow_BtnClick.js b/src/so/so/sobalance/card/btnClicks/addRow_BtnClick.js new file mode 100644 index 00000000..4c66f322 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/addRow_BtnClick.js @@ -0,0 +1,11 @@ +/* + * @Author: cuijun + * @PageInfo: 新增行事件 + * @Date: 2018-04-19 10:37:53 + * @Last Modified by: cuijun + * @Last Modified time: 2018-06-08 09:38:39 + */ + +export default function clickAddRowBtn(props) { + props.cardTable.addRow(this.tableId); +} diff --git a/src/so/so/sobalance/card/btnClicks/buttonClick.js b/src/so/so/sobalance/card/btnClicks/buttonClick.js new file mode 100644 index 00000000..49d83c30 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/buttonClick.js @@ -0,0 +1,38 @@ +/* + * @Author: cuijun + * @PageInfo: 按钮点击事件 + * @Date: 2018-04-19 10:37:30 + * @Last Modified by: 刘奇 + * @Last Modified time: 2018-10-20 14:27:19 + */ +import editBtnClick from './edit_BtnClick'; +import cancelBtnClick from './cancel_BtnClick'; +import saveBtnClick from './save_BtnClick'; +import printBtnClick from './print_BtnClick'; +import refreshBtnClick from './refresh_BtnClick'; +import { BUTTONS } from '../../const'; + +export default function clickBtn(props, id) { + switch (id) { + // 取消 + case BUTTONS.CANCEL: + let cancel = cancelBtnClick.bind(this); + return cancel(props); + // 修改 + case BUTTONS.EDIT: + let edit = editBtnClick.bind(this); + return edit(props); + // 保存 + case BUTTONS.SAVE: + let save = saveBtnClick.bind(this); + return save(props); + // 打印 + case BUTTONS.PRINT: + let print = printBtnClick.bind(this); + return print(props); + //刷新 + case BUTTONS.REFRESH: + let refresh = refreshBtnClick.bind(this); + return refresh(props); + } +} diff --git a/src/so/so/sobalance/card/btnClicks/cancel_BtnClick.js b/src/so/so/sobalance/card/btnClicks/cancel_BtnClick.js new file mode 100644 index 00000000..a9be9110 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/cancel_BtnClick.js @@ -0,0 +1,34 @@ +/* + * @Author: cuijun + * @PageInfo: 取消按钮事件 + * @Date: 2018-05-14 21:56:25 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-29 10:17:38 + */ +import { SOBALANCE_CONST } from '../../const'; +import { showCancelDialog } from '../../../../../scmpub/scmpub/pub/tool/messageUtil'; +import { getCurrentLastId } from '../../../../../scmpub/scmpub/pub/cache'; + +export default function clickCancelBtn(props) { + showCancelDialog({ beSureBtnClick: cancel.bind(this, props) }); +} +function cancel(props) { + props.beforeUpdatePage(); + let lastId = ''; + if (this.props.getUrlParam(SOBALANCE_CONST.status) == SOBALANCE_CONST.add) { + lastId = getCurrentLastId(SOBALANCE_CONST.SobalanceCacheKey); + } else { + lastId = this.lastId; + } + props.setUrlParam({ + status: SOBALANCE_CONST.browse, + id: lastId + }); + props.cardTable.resetTableData(SOBALANCE_CONST.tableId); + this.props.form.EmptyAllFormValue(SOBALANCE_CONST.formId); + this.props.cardTable.setTableData(SOBALANCE_CONST.tableId, { rows: [] }); + this.getData(); + // 去除复选框的打钩 + props.cardTable.selectAllRows(SOBALANCE_CONST.tableId, false); + props.updatePage(this.formId, this.tableId); +} diff --git a/src/so/so/sobalance/card/btnClicks/deleteLine_BtnClick.js b/src/so/so/sobalance/card/btnClicks/deleteLine_BtnClick.js new file mode 100644 index 00000000..ddf77609 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/deleteLine_BtnClick.js @@ -0,0 +1,29 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片删行按钮事件 + * @Date: 2018-04-19 10:38:05 + * @Last Modified by: cuijun + * @Last Modified time: 2019-03-08 15:17:00 + */ +import { SOBALANCE_CONST } from '../../const'; +import { showWarningInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; +import rowbtn_Controller from '../init/toggleShow'; + +export default function buttonClick(props, record, index) { + let selIndex = []; + // 点击的肩部按钮 + if (index == undefined) { + let seldatas = props.cardTable.getCheckedRows(SOBALANCE_CONST.tableId); + if (seldatas.length == 0) { + showWarningInfo(null, getLangByResId(this, '4006SOBALANCE-000002')); /* 国际化处理: 请选择要删除的行!*/ + } + seldatas.forEach((item) => { + selIndex.push(item.index); + }); + } else { + selIndex.push(index); + } + props.cardTable.delRowsByIndex(SOBALANCE_CONST.tableId, selIndex); + rowbtn_Controller.call(this); +} \ No newline at end of file diff --git a/src/so/so/sobalance/card/btnClicks/edit_BtnClick.js b/src/so/so/sobalance/card/btnClicks/edit_BtnClick.js new file mode 100644 index 00000000..611c4988 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/edit_BtnClick.js @@ -0,0 +1,35 @@ +/* + * @Author: cuijun + * @PageInfo: 修改按钮事件 + * @Date: 2018-05-14 21:36:49 + * @Last Modified by: wangpju + * @Last Modified time: 2021-09-02 14:13:16 + */ +import buttonController from '../viewController/buttonController'; +import { SOBALANCE_CONST } from '../../const'; +import { ajax } from 'nc-lightapp-front'; + +export default function clickEditBtn(props) { + let id = this.props.getUrlParam(SOBALANCE_CONST.id); + //订单收款合脚编辑校验数据是否saga冻结 + let data = { + pks: [ id ] + }; + ajax({ + url: SOBALANCE_CONST.editUrl, + data: data, + success: (res) => { + if (res.success) { + props.pushTo(SOBALANCE_CONST.Card_URL, { + pagecode: SOBALANCE_CONST.cardPageId, + status: SOBALANCE_CONST.edit, + id: id + }); + this.lastId = id; + buttonController.call(this); + // 去除复选框的打钩 + props.cardTable.selectAllRows(SOBALANCE_CONST.tableId, false); + } + } + }); +} diff --git a/src/so/so/sobalance/card/btnClicks/index.js b/src/so/so/sobalance/card/btnClicks/index.js new file mode 100644 index 00000000..04659540 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/index.js @@ -0,0 +1,4 @@ +import buttonClick from './buttonClick'; +import operateBtnClick from './operate_buttonClick'; +import pageInfoBtnClick from './pageInfo_BtnClick'; +export { buttonClick, operateBtnClick, pageInfoBtnClick }; diff --git a/src/so/so/sobalance/card/btnClicks/insertLine_BtnClick.js b/src/so/so/sobalance/card/btnClicks/insertLine_BtnClick.js new file mode 100644 index 00000000..eed3cc04 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/insertLine_BtnClick.js @@ -0,0 +1,12 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片插入行按钮事件 + * @Date: 2018-04-19 10:38:05 + * @Last Modified by: cuijun + * @Last Modified time: 2018-06-07 21:01:45 + */ +import { SOBALANCE_CONST } from '../../const'; + +export default function buttonClick(props, record, index) { + props.cardTable.addRow(SOBALANCE_CONST.tableId, index); +} diff --git a/src/so/so/sobalance/card/btnClicks/operate_buttonClick.js b/src/so/so/sobalance/card/btnClicks/operate_buttonClick.js new file mode 100644 index 00000000..f80bb4e6 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/operate_buttonClick.js @@ -0,0 +1,24 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片操作列按钮事件 + * @Date: 2018-04-19 10:34:04 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-18 16:11:25 + */ + +import spread_BtnClick from './spread_BtnClick'; +import deleteLine_BtnClick from './deleteLine_BtnClick'; +import addRow_BtnClick from './addRow_BtnClick'; +import { BUTTONS } from '../../const'; + +export default function buttonClick(props, id, text, record, index) { + switch (id) { + // DeleteLine 删行 + case BUTTONS.DELETELINE: + return deleteLine_BtnClick.bind(this)(props, record, index); + //增行 + case BUTTONS.ADDLINE: + return addRow_BtnClick.bind(this)(props, record, index); + break; + } +} diff --git a/src/so/so/sobalance/card/btnClicks/pageInfo_BtnClick.js b/src/so/so/sobalance/card/btnClicks/pageInfo_BtnClick.js new file mode 100644 index 00000000..81329926 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/pageInfo_BtnClick.js @@ -0,0 +1,13 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片下一页点击事件 + * @Date: 2018-04-19 10:34:04 + * @Last Modified by: cuijun + * @Last Modified time: 2018-09-26 13:42:09 + */ + +import { ajax, toast } from 'nc-lightapp-front'; +export default function pageInfo_BtnClick(props, pk) { + props.setUrlParam(pk); + this.getData(); +} diff --git a/src/so/so/sobalance/card/btnClicks/print_BtnClick.js b/src/so/so/sobalance/card/btnClicks/print_BtnClick.js new file mode 100644 index 00000000..542e2e25 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/print_BtnClick.js @@ -0,0 +1,25 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片下打印按钮事件 + * @Date: 2018-04-19 10:38:05 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-16 18:53:58 + */ + +import React, { Component } from 'react'; +import { print, base } from 'nc-lightapp-front'; +import { SOBALANCE_CONST } from '../../const'; + +export default function buttonClick(props) { + let billids = []; + let csaleorderid = props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'csaleorderid').value; + billids.push(csaleorderid); + print( + 'pdf', //支持两类: 'html'为模板打印, 'pdf'为pdf打印 + SOBALANCE_CONST.printUrl, + { + nodekey: null, //模板节点标识 + oids: billids // 功能节点的数据主键 oids含有多个元素(['1001A41000000000A9LR','1001A410000000009JDD'])时为批量打印, + } + ); +} diff --git a/src/so/so/sobalance/card/btnClicks/refresh_BtnClick.js b/src/so/so/sobalance/card/btnClicks/refresh_BtnClick.js new file mode 100644 index 00000000..e61c48bd --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/refresh_BtnClick.js @@ -0,0 +1,12 @@ +/* + * @Author: cuijun + * @PageInfo: 刷新 + * @Date: 2018-05-31 19:45:10 + * @Last Modified by: cuijun + * @Last Modified time: 2018-09-10 14:57:51 + */ +import { BUTTONS } from '../../const'; + +export default function refresh_BtnClick(props) { + this.getData(BUTTONS.REFRESH); +} diff --git a/src/so/so/sobalance/card/btnClicks/save_BtnClick.js b/src/so/so/sobalance/card/btnClicks/save_BtnClick.js new file mode 100644 index 00000000..b1973431 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/save_BtnClick.js @@ -0,0 +1,104 @@ +/* + * @Author: cuijun + * @PageInfo: 保存按钮事件 + * @Date: 2018-05-14 21:48:31 + * @Last Modified by: wangpju + * @Last Modified time: 2021-08-02 13:50:55 + */ + +import { SOBALANCE_CONST } from '../../const'; +import { base, ajax } from 'nc-lightapp-front'; +import { + changeUrlParam, + addCacheData, + updateCacheData, + deleteCacheData, + getNextId +} from '../../../../../scmpub/scmpub/pub/cache'; +import { showSuccessInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; + +export default function clickSaveBtn(props) { + //过滤表格空行 + props.cardTable.filterEmptyRows(SOBALANCE_CONST.tableId, [ 'varbillcode' ], 'include'); + //校验必输项 + let flag = props.validatePageToToast([ + { + name:SOBALANCE_CONST.formId, + type:'form' + },{ + name:SOBALANCE_CONST.tableId, + type:'cardTable' + } + ]); + if(!flag.allPassed){ + return ; + } + let CardData = props.createMasterChildDataSimple(this.pageId, this.formId, this.tableId); + let rows = CardData.body[this.tableId].rows; + let newRows = []; + rows.forEach((row, index) => { + row.values.pseudocolumn = { value: index + '' }; + newRows.push(row); + }); + CardData.body[this.tableId].rows = newRows; + let url = SOBALANCE_CONST.saveUrl; + let csobalanceid = props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'csobalanceid').value; + let csaleorderid = props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'csaleorderid').value; + + this.props.validateToSave(CardData, () => { + ajax({ + url: url, + pageid: this.pageId, + data: CardData, + + success: (res) => { + if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) { + this.props.dealFormulamsg( + res.formulamsg //参数一:返回的公式对象 + ); + } + if (res.success) { + if (res.data) { + props.beforeUpdatePage(); + if (res.data.head && res.data.head[this.formId]) { + props.form.setAllFormValue({ [this.formId]: res.data.head[this.formId] }); + } + if (res.data.body && res.data.body[this.tableId]) { + let fullTableData = props.cardTable.updateDataByRowId( + this.tableId, + res.data.body[this.tableId], + true + ); + res.data.body[this.tableId] = fullTableData; + } + changeUrlParam(props, { status: SOBALANCE_CONST.browse }); + updateCacheData( + props, + 'csaleorderid', + csaleorderid, + res.data, + SOBALANCE_CONST.formId, + SOBALANCE_CONST.SobalanceCacheKey + ); + } else { + let nextId = getNextId(this.props, csaleorderid, SOBALANCE_CONST.SobalanceCacheKey); + deleteCacheData(props, 'csaleorderid', csaleorderid, SOBALANCE_CONST.SobalanceCacheKey); + csaleorderid = nextId; + props.form.EmptyAllFormValue(SOBALANCE_CONST.formId); + props.cardTable.setTableData(SOBALANCE_CONST.tableId, { rows: [] }); + } + showSuccessInfo(getLangByResId(this, '4006SOBALANCE-000003')); /* 国际化处理: 保存成功!*/ + changeUrlParam(props, { + status: SOBALANCE_CONST.browse, + id: csaleorderid + }); + props.updatePage(SOBALANCE_CONST.formId, SOBALANCE_CONST.tableId); + this.getData(); + // 去除复选框的打钩 + props.cardTable.selectAllRows(SOBALANCE_CONST.tableId, false); + } + } + }); + }); +} diff --git a/src/so/so/sobalance/card/btnClicks/spread_BtnClick.js b/src/so/so/sobalance/card/btnClicks/spread_BtnClick.js new file mode 100644 index 00000000..439320a5 --- /dev/null +++ b/src/so/so/sobalance/card/btnClicks/spread_BtnClick.js @@ -0,0 +1,17 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片展开按钮事件 + * @Date: 2018-04-19 10:38:05 + * @Last Modified by: cuijun + * @Last Modified time: 2018-06-07 22:06:15 + */ +import { SOBALANCE_CONST } from '../../const'; + +export default function buttonClick(props, record, index) { + let status = props.cardTable.getStatus(SOBALANCE_CONST.tableId); + if (status === SOBALANCE_CONST.browse) { + props.cardTable.toggleRowView(SOBALANCE_CONST.tableId, record); + } else { + props.cardTable.openModel(SOBALANCE_CONST.tableId, SOBALANCE_CONST.edit, record, index); + } +} diff --git a/src/so/so/sobalance/card/events/afterEvent.js b/src/so/so/sobalance/card/events/afterEvent.js new file mode 100644 index 00000000..79abc8d1 --- /dev/null +++ b/src/so/so/sobalance/card/events/afterEvent.js @@ -0,0 +1,17 @@ +/* + * @Author: cuijun + * @PageInfo: 编辑事件 + * @Date: 2018-05-18 11:29:36 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-27 14:49:02 + */ + +import { SOBALANCE_CONST } from '../../const'; +import bodyEvents from './body_afterEvent'; + +export default function afterEvent(props, moduleId, key, value, rows, i, s, g) { + if (moduleId === SOBALANCE_CONST.tableId) { + //表体区域改变 + bodyEvents.call(this, props, moduleId, key, value, rows, i, s, g); + } +} diff --git a/src/so/so/sobalance/card/events/body_afterEvent.js b/src/so/so/sobalance/card/events/body_afterEvent.js new file mode 100644 index 00000000..deb7b257 --- /dev/null +++ b/src/so/so/sobalance/card/events/body_afterEvent.js @@ -0,0 +1,64 @@ +/* + * @Author: cuijun + * @PageInfo: 表体编辑后事件 + * @Date: 2018-05-218 10:37:43 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-13 13:52:10 + */ + +import { ajax, toast } from 'nc-lightapp-front'; +import { SOBALANCE_CONST } from '../../const'; +import { processBillCardBodyEditResult } from '../../../../../scmpub/scmpub/pub/tool/afterEditUtil'; +let pagecode = SOBALANCE_CONST.cardPageId; +let tableId = SOBALANCE_CONST.tableId; +let formId = SOBALANCE_CONST.formId; + +export default function bodyAfterEvent(props, moduleId, key, value, changedrows, i, record) { + // 如果值未改变,不走编辑事件 + let ischange = false; + changedrows.forEach((element) => { + if (JSON.stringify(element.newvalue.value || {}) != JSON.stringify(element.oldvalue.value || {})) { + ischange = true; + return; + } + }); + if (!ischange) { + return; + } + if (key == 'varbillcode') { + //let data = createBodyAfterEventData(props, pagecode, formId, tableId, moduleId, key, changedrows, i); + let data = props.createBodyAfterEventData(pagecode, formId, tableId, moduleId, key, changedrows); + data.index = 0; + // 处理编辑传递单行处理 + let rows = data.card.body[tableId].rows; + let newRows = [ rows[i] ]; + data.card.body[tableId].rows = newRows; + // userObject 处理 + let userobject = {}; + userobject['scm_originindex'] = i + ''; + data.userobject = userobject; + + ajax({ + url: SOBALANCE_CONST.bodyAfterEdit, + data: data, + async: false, + success: (res) => { + if (res.data) { + if (res.data.billCard.head) { + props.form.setAllFormValue({ [formId]: res.data.billCard.head[formId] }); + } + if (res.data.billCard.body) { + setTimeout(() => { + let record = res.data; + record.billCard.body[tableId].rows.forEach(function(value, index) { + record.billCard.body[tableId].rows[index].values.varbillcode.display = + record.billCard.body[tableId].rows[index].values.varbillcode.value; + }); + processBillCardBodyEditResult(props, moduleId, record, i); + }, 0); + } + } + } + }); + } +} diff --git a/src/so/so/sobalance/card/events/body_beforeEvent.js b/src/so/so/sobalance/card/events/body_beforeEvent.js new file mode 100644 index 00000000..4556e33c --- /dev/null +++ b/src/so/so/sobalance/card/events/body_beforeEvent.js @@ -0,0 +1,77 @@ +import { SOBALANCE_CONST } from '../../const'; + +/* + * @Author: cuijun + * @PageInfo: 表体编辑前事件 + * @Date: 2018-06-05 18:25:15 + * @Last Modified by: yangls7 + * @Last Modified time: 2021-04-15 10:34:06 + */ + +export default async function bodyBeforeEvent(props, moduleId, key, index, value, rowdata) { + let record = rowdata.values; + // 收款单单据号 + if (key === 'varbillcode') { + return varbillcodeBeforeEdit.bind(this)(moduleId, key, index, value, record); + // 本次订单核销金额编辑前 + } else if (key === 'norigthisbalmny') { + return norigthisbalmnyBeforeEdit.bind(this)(moduleId, key, index, value, record); + } + return true; +} + +/** + * 收款单单据号编辑前事件 + */ +function varbillcodeBeforeEdit(moduleId, key, index, value, record) { + //税价合计 + let ntotalorigtaxmny = (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'ntotalorigtaxmny') || {}).value; + //核销类型 + let fibaltype = (record.fibaltype || {}).value; + // 只有订单核销行或者表头金额合计不等于0可以编辑 + if (fibaltype == '1' || ntotalorigtaxmny == '0') { + return false; + } + // 收款单参照 + let CardData = this.props.createMasterChildDataSimple( + SOBALANCE_CONST.cardPageId, + SOBALANCE_CONST.formId, + SOBALANCE_CONST.tableId + ); + + this.props.cardTable.setQueryCondition(SOBALANCE_CONST.tableId, { + [key]: () => { + return { + pk_saleorg: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'SoBalanceHVO.CARORGID') || {}) + .value, + scm_so_org: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'pk_org') || {}).value, + money: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'ntotalorigtaxmny') || {}).value, + pk_org: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'carorgid') || {}).value, + scm_pk_currtype: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'corigcurrencyid') || {}) + .value, + scm_customer: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'cinvoicecustid') || {}).value, + So_ordertype: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'vtrantypecode') || {}).value, + Sett_org: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'csaleorderid') || {}).value, + So_psndoc: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'cemployeeid') || {}).value, + So_transtype: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'cchanneltypeid') || {}).value, + Ordercubasdoc: (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'ccustomerid') || {}).value, + GridRefActionExt: 'nccloud.web.so.sobalance.ref.PaybillRefFilterUtils' + }; + } + }); + return true; +} +/** + * 本次订单核销金额编辑前事件 + */ +function norigthisbalmnyBeforeEdit(moduleId, key, index, value, record) { + // 只有订单核销行 + //核销类型 + let fibaltype = record.fibaltype; + // 核销类型为订单收款核销才可以编辑 + if (fibaltype.value === '1') { + return false; + } else { + return true; + } +} diff --git a/src/so/so/sobalance/card/events/index.js b/src/so/so/sobalance/card/events/index.js new file mode 100644 index 00000000..5c1c1be7 --- /dev/null +++ b/src/so/so/sobalance/card/events/index.js @@ -0,0 +1,4 @@ +import afterEvent from './afterEvent'; +import bodyBeforeEvent from './body_beforeEvent'; +import switchController from './switchController' +export { afterEvent, bodyBeforeEvent,switchController }; diff --git a/src/so/so/sobalance/card/events/switchController.js b/src/so/so/sobalance/card/events/switchController.js new file mode 100644 index 00000000..eacc7d23 --- /dev/null +++ b/src/so/so/sobalance/card/events/switchController.js @@ -0,0 +1,11 @@ +/* + * @Author: cuijun + * @PageInfo: 切换视图按钮控制 + * @Date: 2018-06-05 18:25:15 + * @Last Modified by: cuijun + * @Last Modified time: 2018-11-02 11:19:49 + */ + +export default function switchController() { + return false; +} diff --git a/src/so/so/sobalance/card/index.js b/src/so/so/sobalance/card/index.js new file mode 100644 index 00000000..5f802338 --- /dev/null +++ b/src/so/so/sobalance/card/index.js @@ -0,0 +1,285 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片页面 + * @Date: 2018-05-14 13:06:33 + * @Last Modified by: zhangllb + * @Last Modified time: 2022-07-26 16:17:07 + */ + +import React, { Component } from 'react'; +import { createPage, ajax, base, toast } from 'nc-lightapp-front'; +import { showWarningInfo, showSuccessInfo } from '../../../../scmpub/scmpub/pub/tool/messageUtil'; +import { initTemplate, rowbtn_Controller } from './init'; +import { buttonClick, operateBtnClick, pageInfoBtnClick } from './btnClicks'; +import buttonController from './viewController/buttonController'; +import { SOBALANCE_CONST, BUTTON_AREA, BUTTONS } from '../const'; +import { afterEvent, bodyBeforeEvent, switchController } from './events'; +import { getCacheDataByPk, updateCacheData } from '../../../../scmpub/scmpub/pub/cache'; +import { initLang, getLangByResId } from '../../../../scmpub/scmpub/pub/tool/multiLangUtil'; +import { createCardTitle } from '../../../../scmpub/scmpub/pub/tool/titleUtil'; +import { showSagaErrorToast } from '../../../../scmpub/scmpub/pub/tool/sagaMessageUtils'; + +let { NCAffix, NCDiv } = base; +class SoBalanceCard extends Component { + constructor(props) { + super(props); + this.formId = SOBALANCE_CONST.formId; + this.tableId = SOBALANCE_CONST.tableId; + this.pageId = SOBALANCE_CONST.cardPageId; + this.lastId = ''; + props.use.form(this.formId); + props.use.cardTable(this.tableId); + this.state = { + billcode: '' + }; + } + componentWillMount() { + initLang(this, [ '4006sobalance' ], 'so', initTemplate.bind(this, this.props)); + // 关闭浏览器 + window.onbeforeunload = () => { + let status = this.props.cardTable.getStatus(SOBALANCE_CONST.tableId); + if (status == SOBALANCE_CONST.edit || status == SOBALANCE_CONST.add) { + return getLangByResId(this, '4006SOBALANCE-000004'); /* 国际化处理: 当前单据未保存,您确认离开此页面?*/ + } + }; + } + getData = (button) => { + let billcodeStr = ''; + let data = { pk: this.props.getUrlParam(SOBALANCE_CONST.id), pageid: this.pageId }; + let status = this.props.getUrlParam(SOBALANCE_CONST.status); + //无pk时,显示空页面 + if (data.pk === undefined || data.pk == null || data.pk == 'null') { + this.props.beforeUpdatePage(); + this.props.BillHeadInfo.setBillHeadInfoVisible({ + billCode: billcodeStr + }); + this.props.form.EmptyAllFormValue(SOBALANCE_CONST.formId); + this.props.cardTable.setTableData(this.tableId, { rows: [] }); + buttonController.call(this); + this.props.updatePage(SOBALANCE_CONST.formId, SOBALANCE_CONST.tableId); + return; + } else { + //缓存上次操作的单据号, + if (!this.lastId) { + this.lastId = this.props.getUrlParam(SOBALANCE_CONST.id); + } + let cacheData = getCacheDataByPk( + this.props, + SOBALANCE_CONST.SobalanceCacheKey, + this.props.getUrlParam(SOBALANCE_CONST.id) + ); + //缓存中取卡片页面数据 + if ((!button || button != BUTTONS.REFRESH) && cacheData) { + this.props.beforeUpdatePage(); + billcodeStr = cacheData.head[SOBALANCE_CONST.formId].rows[0].values.vbillcode.value; + this.props.form.setAllFormValue({ + [SOBALANCE_CONST.formId]: cacheData.head[SOBALANCE_CONST.formId] + }); + this.props.cardTable.setTableData(SOBALANCE_CONST.tableId, cacheData.body[SOBALANCE_CONST.tableId]); + this.props.BillHeadInfo.setBillHeadInfoVisible({ + billCode: billcodeStr + }); + // 设置按钮可用性 + buttonController.call(this); + this.showSagaMassage.call(this, this.props); + this.props.updatePage(SOBALANCE_CONST.formId, SOBALANCE_CONST.tableId); + return; + } else { + ajax({ + url: SOBALANCE_CONST.queryCardUrl, + data: data, + success: (res) => { + if (res.success) { + if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) { + this.props.dealFormulamsg( + res.formulamsg //参数一:返回的公式对象 + ); + } + this.props.beforeUpdatePage(); + if ( + (!res.data || + !res.data.head || + !res.data.body || + res.data.body[this.tableId].rows.length == 0) && + status == SOBALANCE_CONST.browse + ) { + showWarningInfo( + null, + getLangByResId(this, '4006SOBALANCE-000005') + ); /* 国际化处理: 数据已经被删除,请返回列表界面!*/ + this.props.form.EmptyAllFormValue(this.formId); + this.props.cardTable.setTableData(this.tableId, { rows: [] }); + this.props.BillHeadInfo.setBillHeadInfoVisible({ + billCode: '' + }); + buttonController.call(this); + return; + } else { + if (res.data.head) { + this.props.form.setAllFormValue({ [this.formId]: res.data.head[this.formId] }); + this.props.BillHeadInfo.setBillHeadInfoVisible({ + billCode: res.data.head[this.formId].rows[0].values.vbillcode.value + }); + } + if (res.data.body && res.data.body[this.tableId].rows.length > 0) { + for (let i = 0; i < res.data.body[this.tableId].rows.length; i++) { + res.data.body[this.tableId].rows[i].values.varbillcode.display = + res.data.body[this.tableId].rows[i].values.varbillcode.value; + } + this.props.cardTable.setTableData(this.tableId, res.data.body[this.tableId]); + //表体数据为空时,不更新缓存 + updateCacheData( + this.props, + 'csaleorderid', + data.pk, + res.data, + SOBALANCE_CONST.formId, + SOBALANCE_CONST.SobalanceCacheKey + ); + } + if (button == BUTTONS.REFRESH) { + showSuccessInfo(getLangByResId(this, '4006SOBALANCE-000012')); /* 国际化处理: 刷新成功!*/ + } + } + } else { + this.props.form.EmptyAllFormValue(this.formId); + this.props.cardTable.setTableData(this.tableId, { rows: [] }); + this.props.BillHeadInfo.setBillHeadInfoVisible({ + billCode: '' + }); + props.setUrlParam({ + status: SOBALANCE_CONST.browse, + id: '' + }); + } + buttonController.call(this); + this.showSagaMassage.call(this, this.props); + + this.props.updatePage(SOBALANCE_CONST.formId, SOBALANCE_CONST.tableId); + } + }); + } + } + }; + + showSagaMassage = (props) => { + if (props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'saga_gtxid')) { + showSagaErrorToast(props, { + gtxid: props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'saga_gtxid').value, + billpk: props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'csobalanceid').value + }); + } + }; + + //获取列表肩部信息 + getTableHead = () => { + return this.props.getUrlParam(SOBALANCE_CONST.status) == SOBALANCE_CONST.edit || + this.props.getUrlParam(SOBALANCE_CONST.status) == SOBALANCE_CONST.add ? ( +
+
+ {/* 新增行按钮 */} + {this.props.button.createButtonApp({ + area: BUTTON_AREA.Card_Body, + buttonLimit: 3, + onButtonClick: operateBtnClick.bind(this) + //popContainer: document.querySelector('.header-button-area') + })} +
+
+ ) : ( + '' + ); + }; + + // 点击返回 + clickReturn = () => { + this.props.pushTo(SOBALANCE_CONST.List_URL, { + pagecode: SOBALANCE_CONST.listPageId + }); + }; + + // 主方法 + render() { + let { cardTable, form, button, modal, cardPagination, socket } = this.props; + const { createCardPagination } = cardPagination; + const { createForm } = form; + let { createCardTable } = cardTable; + let { createButtonApp } = button; + return ( +
+ {socket.connectMesg({ + headBtnAreaCode: BUTTON_AREA.Card_Head, // 表头按钮区域ID + formAreaCode: SOBALANCE_CONST.formId, // 表头Form区域ID + billpkname: 'csobalanceid', + dataSource: SOBALANCE_CONST.SobalanceCacheKey + })} +
+ + +
+ + {createCardTitle(this, { + billCode: this.state.billcode, + backBtnClick: this.clickReturn.bind(this) + })} + +
+
+ {this.props.button.createErrorFlag({ + headBtnAreaCode: BUTTON_AREA.Card_Head + })} + {createButtonApp({ + area: BUTTON_AREA.Card_Head, + buttonLimit: 4, + onButtonClick: buttonClick.bind(this) + // popContainer: document.querySelector('.header-button-area') + })} +
+
+ {createCardPagination({ + handlePageInfoChange: pageInfoBtnClick.bind(this), + dataSource: SOBALANCE_CONST.SobalanceCacheKey + })} +
+
+
+ {/* 表头 */} +
+ {createForm(this.formId, { + onAfterEvent: afterEvent.bind(this) + })} +
+
+
+ {/* 表体 */} +
+ {createCardTable(this.tableId, { + tableHead: this.getTableHead.bind(this), + showCheck: true, + showIndex: true, + onSelected: rowbtn_Controller.bind(this), + onSelectedAll: rowbtn_Controller.bind(this), + onBeforeEvent: bodyBeforeEvent.bind(this), + onAfterEvent: afterEvent.bind(this), + hideSwitch: switchController.bind(this), + adaptionHeight: true, + onBatchSelected: rowbtn_Controller.bind(this) + })} +
+
+
+ ); + } +} +SoBalanceCard = createPage({ + billinfo: { + billtype: 'card', + pagecode: SOBALANCE_CONST.cardPageId, + headcode: SOBALANCE_CONST.formId, + bodycode: { + [SOBALANCE_CONST.tableId]: 'cardTable' //此处发生变化了,需要传一个对象 + } + }, + orderOfHotKey: [ SOBALANCE_CONST.formId, SOBALANCE_CONST.tableId ] +})(SoBalanceCard); +export default SoBalanceCard; diff --git a/src/so/so/sobalance/card/init/index.js b/src/so/so/sobalance/card/init/index.js new file mode 100644 index 00000000..f450e019 --- /dev/null +++ b/src/so/so/sobalance/card/init/index.js @@ -0,0 +1,3 @@ +import initTemplate from './initTemplate'; +import rowbtn_Controller from './toggleShow'; +export { initTemplate, rowbtn_Controller }; diff --git a/src/so/so/sobalance/card/init/initCardRowButtons.js b/src/so/so/sobalance/card/init/initCardRowButtons.js new file mode 100644 index 00000000..31cccc1b --- /dev/null +++ b/src/so/so/sobalance/card/init/initCardRowButtons.js @@ -0,0 +1,25 @@ +/* + * @Author: cuijun + * @PageInfo: 初始化列表状态下行按钮 + * @Date: 2018-04-19 10:32:11 + * @Last Modified by: cuijun + * @Last Modified time: 2018-05-31 16:32:22 + */ +import { BUTTON_AREA, LIST_INNER_BUTTONS } from '../../const'; +import { operateBtnClick } from '../btnClicks'; + +export default function(props, text, record, index) { + return props.getUrlParam('status')==='edit' ? ( + props.button.createOprationButton(LIST_INNER_BUTTONS.C_Edit, { + area: BUTTON_AREA.Card_Body_Inner, + buttonLimit: 2, + onButtonClick: (props, key) => operateBtnClick.bind(this)(props, key, text, record, index) + }) + ):( + props.button.createOprationButton(LIST_INNER_BUTTONS.C_Browse, { + area: BUTTON_AREA.Card_Body_Inner, + buttonLimit: 2, + onButtonClick: (props, key) => operateBtnClick.bind(this)(props, key, text, record, index) + }) + ); +} diff --git a/src/so/so/sobalance/card/init/initTemplate.js b/src/so/so/sobalance/card/init/initTemplate.js new file mode 100644 index 00000000..3a9a0498 --- /dev/null +++ b/src/so/so/sobalance/card/init/initTemplate.js @@ -0,0 +1,64 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片初始化模板 + * @Date: 2018-05-14 13:36:31 + * @Last Modified by: cuijun + * @Last Modified time: 2018-10-22 18:30:28 + */ + +import { base, ajax } from 'nc-lightapp-front'; +import { SOBALANCE_CONST, BUTTON_AREA } from '../../const'; +import initCardRowButtons from './initCardRowButtons'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; + +let { NCPopconfirm } = base; +let tableId = SOBALANCE_CONST.tableId; +let pagecode = SOBALANCE_CONST.cardPageId; +let formId = SOBALANCE_CONST.formId; //'head'; + +export default function(props) { + let _this = this; + props.createUIDom( + { + pagecode: pagecode //卡片页面编码 + }, + callbackFun + ); + function callbackFun(data) { + if (data) { + if (data.button) { + let button = data.button; + props.button.hideButtonsByAreas([ BUTTON_AREA.Card_Head, BUTTON_AREA.Card_Body ]); + props.button.setOprationBtnsRenderStatus([ BUTTON_AREA.Card_Body_Inner ], false); + props.button.setButtons(button); + } + if (data.template) { + let meta = data.template; + modifierMeta.call(_this, props, meta); + props.meta.setMeta(meta, _this.getData()); + } + } + } +} + +function modifierMeta(props, meta) { + status = props.cardTable.getStatus(SOBALANCE_CONST.tableId); + meta[formId].status = status; + meta[tableId].status = status; + props.cardTable.setStatus(SOBALANCE_CONST.formId, status); + props.cardTable.setStatus(SOBALANCE_CONST.tableId, status); + + let porCol = { + attrcode: 'opr', + label: getLangByResId(this, '4006SOBALANCE-000007') /* 国际化处理: 操作*/, + width: '150px', + visible: true, + fixed: 'right', + itemtype: 'customer', + render(text, record, index) { + return initCardRowButtons.bind(this, props, text, record, index)(); + } + }; + meta[tableId].items.push(porCol); + return meta; +} diff --git a/src/so/so/sobalance/card/init/toggleShow.js b/src/so/so/sobalance/card/init/toggleShow.js new file mode 100644 index 00000000..0c83fdd5 --- /dev/null +++ b/src/so/so/sobalance/card/init/toggleShow.js @@ -0,0 +1,24 @@ +/* + * @Author: cuijun + * @PageInfo: 根据页面状态设置按钮显示 + * @Date: 2018-09-19 11:45:07 + * @Last Modified by: cuijun + * @Last Modified time: 2020-03-17 15:30:45 + */ +import { SOBALANCE_CONST, BUTTONS } from '../../const'; + +export default function() { + // 处理肩部按钮可用性 + if ( + this.props.getUrlParam(SOBALANCE_CONST.status) == 'edit' || + this.props.getUrlParam(SOBALANCE_CONST.status) == 'add' + ) { + let selrows = this.props.cardTable.getCheckedRows(SOBALANCE_CONST.tableId); + let buttons = [ BUTTONS.DELETELINE ]; + if (selrows != undefined && selrows.length > 0) { + this.props.button.setButtonDisabled(buttons, false); + } else { + this.props.button.setButtonDisabled(buttons, true); + } + } +} diff --git a/src/so/so/sobalance/card/viewController/buttonController.js b/src/so/so/sobalance/card/viewController/buttonController.js new file mode 100644 index 00000000..264f5188 --- /dev/null +++ b/src/so/so/sobalance/card/viewController/buttonController.js @@ -0,0 +1,94 @@ +/* + * @Author: cuijunf + * @PageInfo: 根据页面状态设置按钮显示 + * @Date: 2018-05-26 11:45:07 + * @Last Modified by: cuijun + * @Last Modified time: 2019-11-27 14:21:26 + */ +import { SOBALANCE_CONST, CARD_BODY_BUTTONS, CARD_HEAD_BUTTONS, BUTTON_AREA } from '../../const'; +import { rowbtn_Controller } from '../init'; + +export default function() { + let status = this.props.getUrlParam(SOBALANCE_CONST.status); + if (status === SOBALANCE_CONST.add) { + status = SOBALANCE_CONST.edit; + } + // 1.设置界面状态 + setUIState.call(this, status); + let flag = status === SOBALANCE_CONST.edit ? true : false; + + // 2.设置按钮的显示隐藏 + setCardButtonVisiable.call(this, flag); + // 3.设置主按钮 + setMainButton.call(this); + + // 4.返回按钮的显示隐藏 + setBackButtonVisiable.call(this, flag); + + // 5.设置卡片分页器的显示隐藏 + setCardPaginationVisible.call(this, flag); + // 6.设置其他按钮的显示隐藏 + setOtherButtonVisible.call(this, status); +} + +function setUIState(status) { + if (status == SOBALANCE_CONST.edit || status == SOBALANCE_CONST.add) { + //编辑态 + this.props.form.setFormStatus(SOBALANCE_CONST.formId, SOBALANCE_CONST.edit); + this.props.cardTable.setStatus(SOBALANCE_CONST.tableId, SOBALANCE_CONST.edit); + } else { + //浏览态 + this.props.form.setFormStatus(SOBALANCE_CONST.formId, status); + this.props.cardTable.setStatus(SOBALANCE_CONST.tableId, status); + } +} +function setCardButtonVisiable(flag) { + let pk = this.props.getUrlParam(SOBALANCE_CONST.id); + if (flag) { + this.props.button.setButtonVisible(CARD_HEAD_BUTTONS.ALL, false); + this.props.button.setButtonVisible(CARD_HEAD_BUTTONS.EDIT, true); + this.props.form.setFormItemsDisabled(SOBALANCE_CONST.formId, { pk_org: true }); + //设置肩部按钮全不显示 + this.props.button.setButtonVisible(CARD_BODY_BUTTONS.ALL, false); + //设置肩部按钮显示部分 + this.props.button.setButtonVisible(CARD_BODY_BUTTONS.EDIT, true); + } else { + if (pk && pk != null && pk != 'null') { + this.props.button.setButtonVisible(CARD_HEAD_BUTTONS.ALL, false); + this.props.button.setButtonVisible(CARD_HEAD_BUTTONS.BROWSE, true); + //设置肩部按钮全不显示 + this.props.button.setButtonVisible(CARD_BODY_BUTTONS.ALL, false); + //设置肩部按钮显示部分 + this.props.button.setButtonVisible(CARD_BODY_BUTTONS.BROWSE, true); + } else { + //隐藏翻页控件 + this.props.cardPagination.setCardPaginationVisible('cardPaginationBtn', false); + this.props.button.setButtonVisible(CARD_HEAD_BUTTONS.ALL, false); + //设置肩部按钮全不显示 + this.props.button.setButtonVisible(CARD_BODY_BUTTONS.ALL, false); + } + //根据saga冻结状态控制按钮显示 + let saga_status = (this.props.form.getFormItemsValue(SOBALANCE_CONST.formId, 'saga_status') || {}).value; + if (saga_status == 1) { + this.props.button.toggleErrorStatus(BUTTON_AREA.Card_Head, { + isError: true + }); + } else { + this.props.button.toggleErrorStatus(BUTTON_AREA.Card_Head, { + isError: false + }); + } + } +} +function setOtherButtonVisible(status) { + rowbtn_Controller.call(this); +} +function setMainButton() {} +function setBackButtonVisiable(flag) { + this.props.BillHeadInfo.setBillHeadInfoVisible({ + showBackBtn: !flag //控制显示返回按钮: true为显示,false为隐藏 ---非必传 + }); +} +function setCardPaginationVisible(flag) { + this.props.cardPagination.setCardPaginationVisible('cardPaginationBtn', !flag); +} diff --git a/src/so/so/sobalance/const/const.js b/src/so/so/sobalance/const/const.js new file mode 100644 index 00000000..51ab2e8d --- /dev/null +++ b/src/so/so/sobalance/const/const.js @@ -0,0 +1,83 @@ +/* + * @Author: cuijun + * @PageInfo: 订单收款核销常量 + * @Date: 2018-05-11 10:40:02 + * @Last Modified by: cuijun + * @Last Modified time: 2019-11-21 18:26:38 + */ + +const SOBALANCE_CONST = { + SobalanceCacheKey: 'SobalanceCacheKey', + id: 'id', + status: 'status', + formId: 'so_balance', //表头区域 + tableId: 'so_balance_b', //表体区域 + cardPageId: '400600406_card', //卡片pagecode + listPageId: '400600406_list', //列表pagecode + searchId: 'headquery', + moduleId: '4006', //模块id + browse: 'browse', //状态 + edit: 'edit', + add: 'add', + bodyAfterEdit: '/nccloud/so/sobalance/bodyAfterEditEvent.do', //卡片态表体编辑后事件处理 + Card_URL: '/card', + List_URL: '/list', + queryCardUrl: '/nccloud/so/sobalance/cardQuery.do', + queryListUrl: '/nccloud/so/sobalance/listQuery.do', + queryListPageUrl: '/nccloud/so/sobalance/queryForPage.do', + saveUrl: '/nccloud/so/sobalance/save.do', + printUrl: '/nccloud/so/sobalance/print.do', + editUrl: '/nccloud/so/sobalance/edit.do' +}; +// 按钮区域常亮 +const BUTTON_AREA = { + List_Head: 'list_head', + List_Inner: 'list_inner', + Card_Head: 'card_head', + Card_Body: 'card_body', + Card_Body_Inner: 'card_body_inner' +}; +// 根据状态不同,显示不同的行操作按钮 +const LIST_INNER_BUTTONS = { + C_Edit: [ 'DeleteLine', 'InsertLine' ], + C_Browse: [] +}; + +// 卡片浏览态,肩部显示的按钮 +const CARD_BODY_BROWSE_BUTTONS = []; +// 卡片编辑态,肩部显示的按钮 +const CARD_BODY_EDIT_BUTTONS = [ 'group2', 'AddLine', 'DeleteLine' ]; +const CARD_BODY_ALL_BUTTONS = [ 'group2', 'AddLine', 'DeleteLine' ]; + +const CARD_BODY_BUTTONS = { + EDIT: CARD_BODY_EDIT_BUTTONS, + BROWSE: CARD_BODY_BROWSE_BUTTONS, + ALL: CARD_BODY_ALL_BUTTONS +}; + +const CARD_HEAD_BUTTONS = { + ALL: [ 'group1', 'Save', 'Cancel', 'Edit', 'Print', 'Refresh' ], + BROWSE: [ 'Edit', 'Print', 'Refresh' ], + EDIT: [ 'group1', 'Save', 'Cancel' ] +}; +//所有按钮 +const BUTTONS = { + // 取消 + CANCEL: 'Cancel', + // 修改 + EDIT: 'Edit', + // 保存 + SAVE: 'Save', + // 打印 + PRINT: 'Print', + //删行 + DELETELINE: 'DeleteLine', + //增行 + ADDLINE: 'AddLine', + //刷新 + REFRESH: 'Refresh', + //查询区查询按钮 + LISTQUERY: 'ListQuery' +}; + +export { BUTTON_AREA, SOBALANCE_CONST, LIST_INNER_BUTTONS, CARD_BODY_BUTTONS, CARD_HEAD_BUTTONS, BUTTONS }; diff --git a/src/so/so/sobalance/const/index.js b/src/so/so/sobalance/const/index.js new file mode 100644 index 00000000..420f5187 --- /dev/null +++ b/src/so/so/sobalance/const/index.js @@ -0,0 +1,9 @@ +import { + BUTTON_AREA, + SOBALANCE_CONST, + LIST_INNER_BUTTONS, + CARD_BODY_BUTTONS, + CARD_HEAD_BUTTONS, + BUTTONS +} from './const'; +export { SOBALANCE_CONST, BUTTON_AREA, LIST_INNER_BUTTONS, CARD_BODY_BUTTONS, CARD_HEAD_BUTTONS, BUTTONS }; diff --git a/src/so/so/sobalance/list/btnClicks/buttonClick.js b/src/so/so/sobalance/list/btnClicks/buttonClick.js new file mode 100644 index 00000000..af6bcfdc --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/buttonClick.js @@ -0,0 +1,19 @@ +/* + * @Author: cuijun + * @PageInfo: 按钮事件 + * @Date: 2018-05-11 10:59:20 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-17 20:57:35 + */ +import printBtnClick from './print_BtnClick'; +import refreshBtnClick from './refresh_BtnClick'; +import { BUTTONS } from '../../const'; + +export default function clickBtn(props, id) { + switch (id) { + case BUTTONS.PRINT: + return printBtnClick.bind(this)(props); + case BUTTONS.REFRESH: + return refreshBtnClick.bind(this)(props); + } +} diff --git a/src/so/so/sobalance/list/btnClicks/commonSearch.js b/src/so/so/sobalance/list/btnClicks/commonSearch.js new file mode 100644 index 00000000..48bebce4 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/commonSearch.js @@ -0,0 +1,63 @@ +/* + * @Author: cuijun + * @PageInfo: 查询按钮处理方法 + * @Date: 2018-05-11 10:51:34 + * @Last Modified by: songyt13 + * @Last Modified time: 2022-05-10 15:37:21 + */ + +import { ajax } from 'nc-lightapp-front'; +import { SOBALANCE_CONST, BUTTONS } from '../../const'; +import buttonController from '../viewController/buttonController'; +import { + showWarningInfo, + showSuccessInfo, + showNoQueryResultInfo, + showHasQueryResultInfo +} from '../../../../../scmpub/scmpub/pub/tool/messageUtil'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; + +export default function clickSerachBtn(props, queryInfo, button) { + if (queryInfo == undefined) { + queryInfo = this.props.search.getQueryInfo(SOBALANCE_CONST.searchId, false); + } + let pageInfo = this.props.table.getTablePageInfo(SOBALANCE_CONST.formId); + queryInfo.pageInfo = pageInfo; + ajax({ + url: SOBALANCE_CONST.queryListUrl, + data: queryInfo, + success: (res) => { + if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) { + this.props.dealFormulamsg( + res.formulamsg //参数一:返回的公式对象 + ); + } + let { success, data } = res; + if (success) { + if (data) { + let rowsData = { rows: [] }; + if (res.data && res.data[SOBALANCE_CONST.formId]) { + rowsData = res.data[SOBALANCE_CONST.formId]; + } + this.props.table.setAllTableData(SOBALANCE_CONST.formId, rowsData); + if (button == BUTTONS.REFRESH) { + showSuccessInfo(getLangByResId(this, '4006SOBALANCE-000012')); /* 国际化处理: 刷新成功!*/ + } else if (button == BUTTONS.LISTQUERY) { + let successNum = rowsData.rows.length; + if (successNum) { + showHasQueryResultInfo(successNum); + } else { + showNoQueryResultInfo(); + } + } + } else { + this.props.table.setAllTableData(SOBALANCE_CONST.formId, { rows: [] }); + showNoQueryResultInfo(); + } + } + //查询成功后,刷新按钮可用 + this.props.button.setButtonDisabled(BUTTONS.REFRESH, false); + buttonController.call(this); + } + }); +} diff --git a/src/so/so/sobalance/list/btnClicks/double_BtnClick.js b/src/so/so/sobalance/list/btnClicks/double_BtnClick.js new file mode 100644 index 00000000..5eea722d --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/double_BtnClick.js @@ -0,0 +1,16 @@ +/* + * @Author: cuijun + * @PageInfo: 列表下双击进入卡片界面 + * @Date: 2018-05-17 15:08:59 + * @Last Modified by: wangpju + * @Last Modified time: 2021-09-02 14:13:48 + */ +import { SOBALANCE_CONST } from '../../const'; + +export default function doubleClick(record, index, e) { + this.props.pushTo(SOBALANCE_CONST.Card_URL, { + pagecode: SOBALANCE_CONST.cardPageId, + status: SOBALANCE_CONST.browse, + id: record.csaleorderid.value + }); +} diff --git a/src/so/so/sobalance/list/btnClicks/editBtnClick.js b/src/so/so/sobalance/list/btnClicks/editBtnClick.js new file mode 100644 index 00000000..5ab58e60 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/editBtnClick.js @@ -0,0 +1,29 @@ +/* + * @Author: cuijun + * @PageInfo: 修改按钮处理 + * @Date: 2018-05-11 10:59:43 + * @Last Modified by: wangpju + * @Last Modified time: 2021-09-02 14:13:59 + */ + +import { SOBALANCE_CONST } from '../../const'; +import { ajax } from 'nc-lightapp-front'; + +export default function buttonClick(props, record, index) { + let data = { + pks: [ record.csaleorderid.value ] + }; + ajax({ + url: SOBALANCE_CONST.editUrl, + data: data, + success: (res) => { + if (res.success) { + props.pushTo(SOBALANCE_CONST.Card_URL, { + pagecode: SOBALANCE_CONST.cardPageId, + status: SOBALANCE_CONST.edit, + id: record.csaleorderid.value + }); + } + } + }); +} diff --git a/src/so/so/sobalance/list/btnClicks/index.js b/src/so/so/sobalance/list/btnClicks/index.js new file mode 100644 index 00000000..6a007009 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/index.js @@ -0,0 +1,7 @@ +import buttonClick from './buttonClick'; +import searchBtnClick from './searchBtnClick'; +import pageInfoClick from './pageInfoClick'; +import operateClick from './operate_buttonClick'; +import doubleBtnClick from './double_BtnClick'; + +export { buttonClick, searchBtnClick, pageInfoClick, operateClick, doubleBtnClick }; diff --git a/src/so/so/sobalance/list/btnClicks/listPageData.js b/src/so/so/sobalance/list/btnClicks/listPageData.js new file mode 100644 index 00000000..c2dd250c --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/listPageData.js @@ -0,0 +1,42 @@ +/* + * @Author: cuijun + * @PageInfo: 获取选中数据 + * @Date: 2018-04-19 10:34:04 + * @Last Modified by: cuijun + * @Last Modified time: 2018-08-10 09:55:23 + */ +import { SOBALANCE_CONST } from '../../const'; + +function getSelectedOperaDatas(props, record, index) { + // index : 选中的行数组 + // bills : 选中行的数据数组,包含主键和ts + let res = {}; + let bills = []; + let selIndex = []; + if (index == undefined) { + let selrows = props.table.getCheckedRows(SOBALANCE_CONST.formId); + if (selrows.length == 0) { + return null; + } + selrows.forEach((row) => { + let bill = { + pk: row.data.values.csaleorderid.value, + ts: row.data.values.ts.value + }; + bills.push(bill); + selIndex.push(row.index); + }); + } else { + let bill = { + pk: record.csaleorderid.value, + ts: record.ts.value + }; + bills.push(bill); + selIndex.push(index); + } + res.index = selIndex; + res.bills = bills; + return res; +} + +export default getSelectedOperaDatas; diff --git a/src/so/so/sobalance/list/btnClicks/operate_buttonClick.js b/src/so/so/sobalance/list/btnClicks/operate_buttonClick.js new file mode 100644 index 00000000..41d447c1 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/operate_buttonClick.js @@ -0,0 +1,17 @@ +/* + * @Author: cuijun + * @PageInfo: 列表操作列按钮事件 + * @Date: 2018-04-19 10:34:04 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-06 13:59:23 + */ +import editBtnClick from './editBtnClick'; +import { BUTTONS } from '../../const'; + +export default function buttonClick(props, id, text, record, index) { + switch (id) { + //修改 + case BUTTONS.EDIT: + return editBtnClick.bind(this)(props, record, index); + } +} diff --git a/src/so/so/sobalance/list/btnClicks/pageInfoClick.js b/src/so/so/sobalance/list/btnClicks/pageInfoClick.js new file mode 100644 index 00000000..0aa926ce --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/pageInfoClick.js @@ -0,0 +1,43 @@ +/* + * @Author: cuijun + * @PageInfo: 翻页按钮处理方法 + * @Date: 2018-05-11 11:00:10 + * @Last Modified by: cuijun + * @Last Modified time: 2018-09-18 16:08:50 + */ + +import { ajax } from 'nc-lightapp-front'; +import { SOBALANCE_CONST } from '../../const'; +import buttonController from '../viewController/buttonController'; +export default function (props, config, pks) { + if (pks == null || pks.length == 0) { + props.table.setAllTableData(SOBALANCE_CONST.formId, { rows: [] }); + return; + } + let data = { + pks: pks, + pageid: SOBALANCE_CONST.listPageId + }; + //得到数据渲染到页面 + + ajax({ + url: SOBALANCE_CONST.queryListPageUrl, + data: data, + success: (res) => { + let { success, data } = res; + if (success) { + if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) { + this.props.dealFormulamsg( + res.formulamsg //参数一:返回的公式对象 + ); + } + if (data && data[SOBALANCE_CONST.formId]) { + props.table.setAllTableData(SOBALANCE_CONST.formId, res.data[SOBALANCE_CONST.formId]); + } else { + props.table.setAllTableData(SOBALANCE_CONST.formId, { rows: [] }); + } + buttonController.call(this) + } + } + }); +} diff --git a/src/so/so/sobalance/list/btnClicks/print_BtnClick.js b/src/so/so/sobalance/list/btnClicks/print_BtnClick.js new file mode 100644 index 00000000..f4c51f06 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/print_BtnClick.js @@ -0,0 +1,36 @@ +/* + * @Author: cuijun + * @PageInfo: 卡片下打印按钮事件 + * @Date: 2018-04-19 10:38:05 + * @Last Modified by: cuijun + * @Last Modified time: 2018-10-26 15:17:19 + */ + +import React, { Component } from 'react'; +import { print, base, toast } from 'nc-lightapp-front'; +import { SOBALANCE_CONST } from '../../const'; +import getSelectedOperaDatas from './listPageData'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; +import { showWarningInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil'; + +export default function buttonClick(props) { + let seldatas = getSelectedOperaDatas(props); + + if (seldatas == null || seldatas.index == undefined) { + showWarningInfo(getLangByResId(this, '4006SOBALANCE-000010'), getLangByResId(this, '4006SOBALANCE-000009')); + /* 国际化处理: 提示,请选择要打印的订单!*/ + return; + } + let pks = []; + seldatas.bills.forEach((element) => { + pks.push(element.pk); + }); + print( + 'pdf', //支持两类: 'html'为模板打印, 'pdf'为pdf打印 + SOBALANCE_CONST.printUrl, + { + nodekey: null, //模板节点标识 + oids: pks // 功能节点的数据主键 oids含有多个元素(['1001A41000000000A9LR','1001A410000000009JDD'])时为批量打印, + } + ); +} diff --git a/src/so/so/sobalance/list/btnClicks/refresh_BtnClick.js b/src/so/so/sobalance/list/btnClicks/refresh_BtnClick.js new file mode 100644 index 00000000..9183e4e3 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/refresh_BtnClick.js @@ -0,0 +1,15 @@ +/* + * @Author: cuijun + * @PageInfo: 刷新按钮 + * @Date: 2018-07-03 16:09:38 + * @Last Modified by: cuijun + * @Last Modified time: 2018-10-26 11:14:58 + */ +import { getDefData } from '../../../../../scmpub/scmpub/pub/cache'; +import clickSerachBtn from './commonSearch'; +import { SOBALANCE_CONST, BUTTONS } from '../../const'; + +export default function refresh(props) { + let queryInfo = getDefData(SOBALANCE_CONST.SobalanceCacheKey, SOBALANCE_CONST.searchId); + clickSerachBtn.call(this, props, queryInfo, BUTTONS.REFRESH); +} diff --git a/src/so/so/sobalance/list/btnClicks/searchBtnClick.js b/src/so/so/sobalance/list/btnClicks/searchBtnClick.js new file mode 100644 index 00000000..8a7ae970 --- /dev/null +++ b/src/so/so/sobalance/list/btnClicks/searchBtnClick.js @@ -0,0 +1,23 @@ +/* + * @Author: cuijun + * @PageInfo: 查询按钮处理方法 + * @Date: 2018-05-11 10:51:34 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-18 18:04:53 + */ + +import { SOBALANCE_CONST, BUTTONS } from '../../const'; +import { setDefData } from '../../../../../scmpub/scmpub/pub/cache'; +import commonSearch from './commonSearch'; + +export default function clickSerachBtn(props, serchVal) { + // 缓存查询条件 + if (serchVal == false) { + return; + } + let queryInfo = this.props.search.getQueryInfo(SOBALANCE_CONST.searchId, false); + //缓存查询条件 + setDefData(SOBALANCE_CONST.SobalanceCacheKey, SOBALANCE_CONST.searchId, queryInfo); + setDefData(SOBALANCE_CONST.SobalanceCacheKey, 'initKey', 'search'); + commonSearch.bind(this, props, queryInfo, BUTTONS.LISTQUERY)(); +} diff --git a/src/so/so/sobalance/list/events/index.js b/src/so/so/sobalance/list/events/index.js new file mode 100644 index 00000000..12236c42 --- /dev/null +++ b/src/so/so/sobalance/list/events/index.js @@ -0,0 +1,10 @@ +/* + * @Author: cuijun + * @PageInfo: 价格调整单编辑事件 + * @Date: 2018-04-24 19:01:11 + * @Last Modified by: cuijun + * @Last Modified time: 2018-07-31 09:49:23 + */ +import search_afterEvent from './search_afterEvent'; + +export { search_afterEvent }; diff --git a/src/so/so/sobalance/list/events/search_afterEvent.js b/src/so/so/sobalance/list/events/search_afterEvent.js new file mode 100644 index 00000000..36a5b375 --- /dev/null +++ b/src/so/so/sobalance/list/events/search_afterEvent.js @@ -0,0 +1,26 @@ +/* + * @Author: cuijun + * @PageInfo: 查询编辑后事件 + * @Date: 2018-04-24 10:38:43 + * @Last Modified by: cuijun + * @Last Modified time: 2018-08-29 10:29:21 + */ + +import { SOBALANCE_CONST } from '../../const'; +import multiCorpRefHandler from '../../../../../scmpub/scmpub/pub/tool/MultiCorpRefHandler'; + +export default function afterEvent(field, value) { + if (field === 'pk_org') { + multiCorpRefHandler.call(this, this.props, value, SOBALANCE_CONST.searchId, [ + 'ccustomerid', + 'ccustomerid.pk_custclass', + 'ccustomerid.sales.pk_custsaleclass', + 'cinvoicecustid', + 'cinvoicecustid.pk_custclass', + 'cinvoicecustid.sales.pk_custsaleclass', + 'cdeptid', + 'cemployeeid', + 'cpaytermid' + ]); + } +} diff --git a/src/so/so/sobalance/list/index.js b/src/so/so/sobalance/list/index.js new file mode 100644 index 00000000..c1cadc39 --- /dev/null +++ b/src/so/so/sobalance/list/index.js @@ -0,0 +1,102 @@ +/* + * @Author: cuijun + * @PageInfo: 订单收款核销 + * @Date: 2018-05-11 11:05:39 + * @Last Modified by: zhangllb + * @Last Modified time: 2022-07-26 16:17:33 + */ + +import React, { Component } from 'react'; +import { createPage, base } from 'nc-lightapp-front'; +import { initTemplate, selected, selectedAll } from './init'; +import { searchBtnClick, pageInfoClick, buttonClick, doubleBtnClick } from './btnClicks'; +import buttonController from './viewController/buttonController'; +import { SOBALANCE_CONST, BUTTON_AREA } from '../const'; +import { search_afterEvent } from './events'; +import { renderCompleteEvent } from '../../pub/queryarea/queryAreaInit'; +import { initLang, getLangByResId } from '../../../../scmpub/scmpub/pub/tool/multiLangUtil'; +import { createListTitle } from '../../../../scmpub/scmpub/pub/tool/titleUtil'; + +const { NCAffix, NCDiv } = base; + +class SoBalanceList extends Component { + constructor(props) { + super(props); + this.moduleId = SOBALANCE_CONST.moduleId; + this.head = SOBALANCE_CONST.formId; // + this.searchId = SOBALANCE_CONST.searchId; + this.pageId = SOBALANCE_CONST.listPageId; + this.queryAreaCode = SOBALANCE_CONST.searchId; + props.use.table(this.head); + props.use.search(this.searchId); + this.state = {}; + } + + componentWillMount() { + initLang(this, [ '4006sobalance' ], 'so', initTemplate.bind(this, this.props)); + } + componentDidMount() {} + + render() { + let { table, button, search, socket } = this.props; + let { createSimpleTable } = table; + let { NCCreateSearch } = search; + let { createButtonApp } = button; + return ( +
+ {socket.connectMesg({ + tableAreaCode: this.head, + billpkname: 'csobalanceid' + })} + + +
{createListTitle(this)}
+
+ {createButtonApp({ + area: BUTTON_AREA.List_Head, + buttonLimit: 8, + onButtonClick: buttonClick.bind(this) + })} +
+
+
+ +
+ {NCCreateSearch(this.searchId, { + clickSearchBtn: searchBtnClick.bind(this), + onAfterEvent: search_afterEvent.bind(this), + dataSource: SOBALANCE_CONST.SobalanceCacheKey, + renderCompleteEvent: renderCompleteEvent.bind( + this, + SOBALANCE_CONST.searchId, + 'pk_org', + search_afterEvent + ) + })} +
+
+ {createSimpleTable(this.head, { + handlePageInfoChange: pageInfoClick.bind(this), + onSelected: selected.bind(this), + onSelectedAll: selectedAll.bind(this), + onRowDoubleClick: doubleBtnClick.bind(this), + showCheck: true, + showIndex: true, + pkname: 'csaleorderid', + dataSource: SOBALANCE_CONST.SobalanceCacheKey, + componentInitFinished: buttonController.bind(this), + onBatchSelected: selected.bind(this) + })} +
+
+ ); + } +} +SoBalanceList = createPage({ + billinfo: { + billtype: 'grid', + pagecode: SOBALANCE_CONST.listPageId, + bodycode: SOBALANCE_CONST.formId + } +})(SoBalanceList); +export default SoBalanceList; diff --git a/src/so/so/sobalance/list/init/index.js b/src/so/so/sobalance/list/init/index.js new file mode 100644 index 00000000..b1572ac1 --- /dev/null +++ b/src/so/so/sobalance/list/init/index.js @@ -0,0 +1,5 @@ +import initTemplate from './initTemplate'; +import selected from './selected'; +import selectedAll from './selectedAll'; + +export { initTemplate, selected, selectedAll }; diff --git a/src/so/so/sobalance/list/init/initTemplate.js b/src/so/so/sobalance/list/init/initTemplate.js new file mode 100644 index 00000000..9ae12582 --- /dev/null +++ b/src/so/so/sobalance/list/init/initTemplate.js @@ -0,0 +1,100 @@ +/* + * @Author: cuijun + * @PageInfo: 列表初始化模板 + * @Date: 2018-05-11 13:20:21 + * @Last Modified by: chaiwx + * @Last Modified time: 2022-05-05 14:37:41 + */ + +import { SOBALANCE_CONST, BUTTON_AREA, BUTTONS } from '../../const'; +import serachRefFilter from '../../refFilter/serachRefFilter'; +import { operateClick } from '../btnClicks'; +import buttonController from '../viewController/buttonController'; +import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil'; +import { getDefData } from '../../../../../scmpub/scmpub/pub/cache'; + +let head = SOBALANCE_CONST.formId; +let pageId = SOBALANCE_CONST.listPageId; + +export default function(props) { + let _this = this; + props.createUIDom( + { + pagecode: pageId //卡片页面编码 + }, + callbackFun + ); + function callbackFun(data) { + if (data) { + if (data.template) { + let meta = data.template; + modifierMeta.call(_this, props, meta); + props.meta.setMeta(meta); + } + if (data.button) { + let button = data.button; + props.button.setButtons(button); + //判断进入列表之前是否查询过 + let isInitEnd = getDefData.call(_this, SOBALANCE_CONST.SobalanceCacheKey, 'initKey'); + if (isInitEnd) { + props.button.setButtonDisabled(BUTTONS.REFRESH, false); + } else { + props.button.setButtonDisabled(BUTTONS.REFRESH, true); + } + } + buttonController.call(_this); + } + } +} + +function modifierMeta(props, meta) { + //查询区参照过滤 + serachRefFilter(props, meta); + meta[head].items = meta[head].items.map((item, key) => { + // item.width = 150; + if (item.attrcode == 'vbillcode') { + item.render = (text, record, index) => { + if (record) { + return ( + { + props.pushTo(SOBALANCE_CONST.Card_URL, { + pagecode: SOBALANCE_CONST.cardPageId, + status: SOBALANCE_CONST.browse, + id: ((record || {}).csaleorderid || {}).value + }); + }} + > + {((record || {}).vbillcode || {}).value} + + ); + } + }; + } + return item; + }); + let buttonAry = [ 'Edit' ]; + let porCol = { + attrcode: 'opr', + label: getLangByResId(this, '4006SOBALANCE-000007') /* 国际化处理: 操作*/, + visible: true, + fixed: 'right', + itemtype: 'customer', + render: (text, record, index) => { + return props.button.createErrorButton({ + record: record, + showBack: true, // 是否显示回退按钮 + sucessCallBack: () => { + return props.button.createOprationButton(buttonAry, { + area: BUTTON_AREA.List_Inner, + buttonLimit: 3, + onButtonClick: (props, key) => operateClick.call(this, props, key, text, record, index) + }); + } + }); + } + }; + meta[head].items.push(porCol); + return meta; +} diff --git a/src/so/so/sobalance/list/init/selected.js b/src/so/so/sobalance/list/init/selected.js new file mode 100644 index 00000000..083771bc --- /dev/null +++ b/src/so/so/sobalance/list/init/selected.js @@ -0,0 +1,12 @@ +/* + * @Author: cuijun + * @PageInfo: checkBox按钮控制 + * @Date: 2018-05-09 11:08:41 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-29 09:39:58 + */ +import buttonController from '../viewController/buttonController'; + +export default function() { + buttonController.call(this); +} diff --git a/src/so/so/sobalance/list/init/selectedAll.js b/src/so/so/sobalance/list/init/selectedAll.js new file mode 100644 index 00000000..bcf60322 --- /dev/null +++ b/src/so/so/sobalance/list/init/selectedAll.js @@ -0,0 +1,12 @@ +/* + * @Author: cuijun + * @PageInfo: checkBox按钮控制 + * @Date: 2018-05-09 11:08:41 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-29 09:40:26 + */ +import buttonController from '../viewController/buttonController'; + +export default function() { + buttonController.call(this); +} diff --git a/src/so/so/sobalance/list/viewController/buttonController.js b/src/so/so/sobalance/list/viewController/buttonController.js new file mode 100644 index 00000000..3b64a4ec --- /dev/null +++ b/src/so/so/sobalance/list/viewController/buttonController.js @@ -0,0 +1,23 @@ +/* + * @Author: cuijun + * @PageInfo: 列表页面按钮控制 + * @Date: 2018-05-23 19:21:24 + * @Last Modified by: cuijun + * @Last Modified time: 2018-12-29 09:33:04 + */ +import { SOBALANCE_CONST, BUTTONS } from '../../const'; + +export default function() { + this.props.button.setButtonDisabled(BUTTONS.PRINT, false); + //根据页面是否有数据 + let allData = this.props.table.getAllTableData(SOBALANCE_CONST.formId); + if (allData.allpks.length > 0) { + let checkedRows = this.props.table.getCheckedRows(SOBALANCE_CONST.formId); + //选中行设置按钮是否可用 + if (!checkedRows || checkedRows.length == 0) { + this.props.button.setButtonDisabled(BUTTONS.PRINT, true); + } + } else { + this.props.button.setButtonDisabled(BUTTONS.PRINT, true); + } +} diff --git a/src/so/so/sobalance/main/config.json b/src/so/so/sobalance/main/config.json new file mode 100644 index 00000000..3b281347 --- /dev/null +++ b/src/so/so/sobalance/main/config.json @@ -0,0 +1,12 @@ +{ + "dependModuleName": [ + "uap/common/components/NCUploader", + "uap/common/components/approvalTrans", + "uap/common/components/ApproveDetail" + ], + "dependjs": [ + "../../../../uap/common/components/NCUploader/index.js", + "../../../../uap/common/components/approvalTrans/index.js", + "../../../../uap/common/components/ApproveDetail/index.js" + ] +} diff --git a/src/so/so/sobalance/main/index.js b/src/so/so/sobalance/main/index.js new file mode 100644 index 00000000..11ccdf30 --- /dev/null +++ b/src/so/so/sobalance/main/index.js @@ -0,0 +1,7 @@ +import {RenderRouter} from 'nc-lightapp-front'; +import routes from './router'; + +(function main(routers,htmlTagid){ + RenderRouter(routers,htmlTagid); +})(routes,"app"); + diff --git a/src/so/so/sobalance/main/router.js b/src/so/so/sobalance/main/router.js new file mode 100644 index 00000000..61f13a9b --- /dev/null +++ b/src/so/so/sobalance/main/router.js @@ -0,0 +1,22 @@ +import { asyncComponent } from 'nc-lightapp-front'; +import SoBalanceList from '../list'; +const SoBalanceCard = asyncComponent(() => + import(/* webpackChunkName: "so/so/sobalance/card/sobalancecard" */ /* webpackMode: "eager" */ '../card') +); +const routes = [ + { + path: '/', + component: SoBalanceList, + exact: true + }, + { + path: '/list', + component: SoBalanceList + }, + { + path: '/card', + component: SoBalanceCard + } +]; + +export default routes; diff --git a/src/so/so/sobalance/refFilter/serachRefFilter.js b/src/so/so/sobalance/refFilter/serachRefFilter.js new file mode 100644 index 00000000..28bdf5da --- /dev/null +++ b/src/so/so/sobalance/refFilter/serachRefFilter.js @@ -0,0 +1,42 @@ +import { SOBALANCE_CONST } from '../const'; +import { setPsndocShowLeavePower, setRefShowDisabledData } from '../../../../scmpub/scmpub/pub/tool'; + +let serachId = SOBALANCE_CONST.searchId; +// 查询区参照过滤 +export default function serachReferEvent(props, meta) { + meta[serachId].items.map((item) => { + if (item.attrcode == 'pk_org') { + item.queryCondition = () => { + return { TreeRefActionExt: 'nccloud.web.scmpub.ref.AppPermissionOrgRefFilter' }; + }; + } + if ( + item.attrcode == 'ccustomerid' || + item.attrcode == 'ccustomerid.pk_custclass' || + item.attrcode == 'ccustomerid.sales.pk_custsaleclass' || + item.attrcode == 'cinvoicecustid' || + item.attrcode == 'cinvoicecustid.pk_custclass' || + item.attrcode == 'cinvoicecustid.sales.pk_custsaleclass' || + item.attrcode == 'cpaytermid' + ) { + item.isShowUnit = true; + item.queryCondition = () => { + let data = props.search.getSearchValByField(serachId, 'pk_org'); + return { pk_org: data && data.value && data.value.firstvalue ? data.value.firstvalue : '' }; // 根据pk_org过滤 + }; + } + if (item.attrcode == 'cemployeeid' || item.attrcode == 'cdeptid') { + item.isShowUnit = true; + item.queryCondition = () => { + let data = props.search.getSearchValByField(serachId, 'pk_org'); + return { + pk_org: data && data.value && data.value.firstvalue ? data.value.firstvalue : '', + busifuncode: 'sa' + }; // 根据pk_org过滤 + }; + } + item.isRunWithChildren = false; + setPsndocShowLeavePower(item); + setRefShowDisabledData(item); + }); +}