From 1dce4484278bac500223072199516f00f17e4921 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 17 Jun 2022 18:06:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E9=9D=A2=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/fieldDefined.js | 24 ++- pc4mobx/organization/stores/baseStore.js | 6 +- pc4mobx/organization/stores/fieldDefined.js | 177 ++++++++++---------- 3 files changed, 116 insertions(+), 91 deletions(-) diff --git a/pc4mobx/organization/apis/fieldDefined.js b/pc4mobx/organization/apis/fieldDefined.js index 8306fbb..155fb2a 100644 --- a/pc4mobx/organization/apis/fieldDefined.js +++ b/pc4mobx/organization/apis/fieldDefined.js @@ -12,7 +12,7 @@ export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getFieldDefinedInfo`, 'GET', params) export const saveFieldDefinedInfo = (moduleName,params) => { - return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveFields`, { method: 'POST', mode: 'cors', headers: { @@ -22,7 +22,16 @@ export const saveFieldDefinedInfo = (moduleName,params) => { }) } -export const removeFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/del`, 'POST', params) +export const removeFieldDefinedInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/del`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} export const saveGroupInfo = (moduleName,params) => { return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, { @@ -83,6 +92,17 @@ export const saveTree = (moduleName,params) => { }) } +export const deleteTree = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/deleteTree`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + export const changeGroup = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/changeGroup`, 'POST', params) export const getEncryptFieldSettingForm = (params = {}) => WeaTools.callApi(`/api/encrypt/fieldsetting/getEncryptFieldSettingForm`, 'GET', params) diff --git a/pc4mobx/organization/stores/baseStore.js b/pc4mobx/organization/stores/baseStore.js index fe5b741..4801715 100644 --- a/pc4mobx/organization/stores/baseStore.js +++ b/pc4mobx/organization/stores/baseStore.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:14:20 - * @LastEditTime: 2022-06-16 18:26:17 + * @LastEditTime: 2022-06-17 10:59:30 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/baseStore.js */ @@ -539,8 +539,8 @@ export default class HrmBaseStore { } return otherParams; } - - //重新计算列 + + convertData = (datas, target) => { let tData = [], selectedData = this.generateTableSelectedData(target); diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index c2950f2..b1c4fe6 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-16 18:34:18 + * @LastEditTime: 2022-06-17 18:05:13 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -202,7 +202,7 @@ export class FieldDefinedStore extends HrmBaseStore { label: '', type: 'INPUT', key: 'fieldname', - viewAttr: '3', + viewAttr: '1', otherParams: { length: 25, regExp: /^[a-zA-Z][a-zA-Z0-9]*$/, @@ -222,7 +222,7 @@ export class FieldDefinedStore extends HrmBaseStore { key: 'fieldType', useRecord: true, colSpan: 1, - width: (this.moduleName === 'resourcefielddefined' && !this.isJobTreeNode) ? "30%" : "40%", + width: "30%", com: [{ label: '', type: 'CUSTOMFIELD', @@ -386,13 +386,13 @@ export class FieldDefinedStore extends HrmBaseStore { getColumns = () => { let columns = cloneDeep(this.fieldDefColumns()) - if (this.moduleName.indexOf('resource') >= 0) { - columns[1].com = [{ - label: '', - type: 'TEXT', - key: 'fieldname', - }] - } + // if (this.moduleName.indexOf('resource') >= 0) { + // columns[1].com = [{ + // label: '', + // type: 'TEXT', + // key: 'fieldname', + // }] + // } return columns; } @@ -464,17 +464,6 @@ export class FieldDefinedStore extends HrmBaseStore { if (this.dialogParams.groupInfoSetting.visible) { let logType = ''; - switch (this.moduleName) { - case 'subcompanyfielddefined': - logType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED_GROUP'; - break; - case 'departmentfielddefined': - logType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED_GROUP'; - break; - case 'resourcefielddefined': - logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED_GROUP'; - break; - } this.editorDialogRightMenu.push(...this.getBasicMenus(logType)); } @@ -697,9 +686,7 @@ export class FieldDefinedStore extends HrmBaseStore { params.groupType = this.selectedTreeNodeInfo.key this.spinning = true; - api.getFieldDefinedInfo(this.moduleName, params).then(response => { - return response.json() - }).then(res => { + api.getFieldDefinedInfo(this.moduleName, params).then(res => { if (res.code === 200) { const { datas, @@ -719,10 +706,9 @@ export class FieldDefinedStore extends HrmBaseStore { } this.spinning = false; this.refreshMainTabComponent = new Date().getTime(); - }).catch(error => { this.spinning = false; - message.warning(error.msg); - }) + this.refreshMainTabComponent = new Date().getTime(); + }, error => {this.spinning = false;}) } @@ -748,7 +734,13 @@ export class FieldDefinedStore extends HrmBaseStore { if (data.code === 200) { message.success(i18n.message.deleteSuccess()); this.tabConfig.activeTabKey = '1'; - this.getTabInfoByTreeNode(); + if(data.data === 0) { + this.getTabInfoByTreeNode(); + }else { + this.initResourceData(this.moduleName) + } + + } else { message.warning(data.msg); } @@ -951,7 +943,8 @@ export class FieldDefinedStore extends HrmBaseStore { }); } - @action saveFieldDefine = () => { + @action("保存按钮") saveFieldDefine = () => { + if (this.spinning) return; this.spinning = true; @@ -984,18 +977,21 @@ export class FieldDefinedStore extends HrmBaseStore { let fieldlabel = d.fieldlabel || '', fieldname = d.fieldname || ''; - if (fieldlabel === '' || (this.moduleName != 'resourcefielddefined' && fieldname === '')) { + if (fieldlabel === '' ) { return true; } labelArr.push(getCurrentLabel(d.fieldlabel)); nameArr.push(d.fieldname); return false; }) - let checkSame = false; - if (this.moduleName.indexOf('resource') >= 0) - checkSame = uniq(labelArr).length === data.length; - else - checkSame = uniq(labelArr).length === data.length && uniq(nameArr).length === data.length; + let checkSame = true; + + //数据库字段名不校验 后端生成 + // if (this.moduleName.indexOf('resource') >= 0) + // checkSame = uniq(labelArr).length === data.length; + // else + // checkSame = uniq(labelArr).length === data.length && uniq(nameArr).length === data.length; + if (invalidEmpty) { this.spinning = false; return; @@ -1008,7 +1004,7 @@ export class FieldDefinedStore extends HrmBaseStore { if (this.selectedTreeNodeInfo != null) dataObj.groupType = this.selectedTreeNodeInfo.key; let params = { - data: JSON.stringify(dataObj) + data: dataObj } if (this.selectedTreeNodeInfo != null) params.groupType = this.selectedTreeNodeInfo.key; @@ -1040,20 +1036,20 @@ export class FieldDefinedStore extends HrmBaseStore { } @action onEdit = (keys, datas, c, dataIndex) => { - if (dataIndex === 'fieldlabel' && this.moduleName != 'resourcefielddefined') { + if (dataIndex === 'fieldlabel') { const oldRecord = this.tableEditConfig.fieldDef.datas[keys[0]]; if (has(oldRecord, 'com') && has(oldRecord.com, 'fieldname') && oldRecord.com.fieldname.length > 0 && oldRecord.com.fieldname[0].type === 'TEXT') { return; } - this.getPinYin({ labelName: getCurrentLabel(datas[0].fieldlabel) }).then(data => { - const { pinyin } = data; - oldRecord.fieldname = pinyin; - const arr = filter(this.tableEditConfig.fieldDef.datas, { fieldname: pinyin }); - if (arr.length > 1 && pinyin != '') { - oldRecord.fieldname = pinyin + '1'; - } - this.refreshFeildDef = new Date().getTime(); - }); + // this.getPinYin({ labelName: getCurrentLabel(datas[0].fieldlabel) }).then(data => { + // const { pinyin } = data; + // oldRecord.fieldname = pinyin; + // const arr = filter(this.tableEditConfig.fieldDef.datas, { fieldname: pinyin }); + // if (arr.length > 1 && pinyin != '') { + // oldRecord.fieldname = pinyin + '1'; + // } + // this.refreshFeildDef = new Date().getTime(); + // }); } } @action onAdd = (keys, datas) => { @@ -1292,7 +1288,7 @@ export class FieldDefinedStore extends HrmBaseStore { } @action("分组维护中删除") onGroupSettingDeleteOpr = (ks, ds, type) => { - debugger + let ids = []; ds.map(d => { if (has(d, 'id')) @@ -1407,6 +1403,8 @@ export class FieldDefinedStore extends HrmBaseStore { if (p.domid === this.treeConfig.selectedKeys[0]) this.selectedTreeNodeInfo = p; p.childs && p.childs.map(c => { + + console.log(this.treeConfig.selectedKeys[0]) if (c.domid === this.treeConfig.selectedKeys[0]) this.selectedTreeNodeInfo = c; }) @@ -1437,7 +1435,10 @@ export class FieldDefinedStore extends HrmBaseStore { this.tableEditConfig.childInfoSetting.showAdd = true; this.tableEditConfig.childInfoSetting.showDelete = true; let domid = this.selectedTreeNodeInfo.domid; - t.topButtonDef.push({ + + let defaultType = domid != '1' && domid != '2' && domid != '3' && domid != '4' + + defaultType && t.topButtonDef.push({ comType: 'button', type: 'primary', onClickHandle: this.doChildInfoSetting, @@ -1445,14 +1446,15 @@ export class FieldDefinedStore extends HrmBaseStore { icon: this.menuIconCollection.setting //checkAction: 'childInfoOperability' }); - //非基本类型() - (domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({ - comType: 'button', - type: 'primary', - onClickHandle: this.removeTypeInfo, - label: i18n.button.delete(), - icon: this.menuIconCollection.setting - }); + + // defaultType && !this.tableEditConfig.childInfoSetting.hasGroup && t.topButtonDef.push({ + // comType: 'button', + // type: 'primary', + // onClickHandle: this.removeTypeInfo, + // label: i18n.button.delete(), + // icon: this.menuIconCollection.setting + // }) + } else { this.tableEditConfig.childInfoSetting.showTitle = false; @@ -1514,7 +1516,7 @@ export class FieldDefinedStore extends HrmBaseStore { this.refreshMainTabComponent = new Date().getTime(); } } else { - message.error(data.message); + message.error(res.message); } }) } @@ -1554,9 +1556,6 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('createChildInfo', true, dialogTitle); } - - - @action("编辑子信息保存(f)") doSaveChildInfo = () => { this.formTarget.childInfoForm.validateForm().then(f => { if (f.isValid) { @@ -1644,6 +1643,7 @@ export class FieldDefinedStore extends HrmBaseStore { @action("子信息维护") doChildInfoSetting = () => { this.tableEditConfig.childInfoSetting.datas.length = 0; let arr = []; + if (!this.selectedTreeNodeInfo.addChild) { arr.push({ "record": { @@ -1733,48 +1733,56 @@ export class FieldDefinedStore extends HrmBaseStore { return arr; } - removeChildInfo = () => { + @action("删除树信息") removeTypeInfo = () => { this.confirmInfo({ content: i18n.confirm.deleteSelected(), onOk: () => { - let parentId; - let cloneTree = cloneDeep(this.toJS(this.treeConfig.data)); - cloneTree.map(p => { - p.childs && p.childs.map((c, i) => { - if (c.domid === this.selectedTreeNodeInfo.domid) { - parentId = p.domid; - p.childs.splice(i, 1); - } - }) - }) + // let parentId; + // let cloneTree = cloneDeep(this.toJS(this.treeConfig.data)); + // cloneTree.map(p => { + // p.childs && p.childs.map((c, i) => { + // if (c.domid === this.selectedTreeNodeInfo.domid) { + // parentId = p.domid; + // p.childs.splice(i, 1); + // } + // }) + // }) + // const params = { + // data: JSON.stringify({ + // records: this.convertAttr(cloneTree) + // }), + // parentId + // } const params = { - data: JSON.stringify({ - records: this.convertAttr(cloneTree) - }), - parentId + id: this.selectedTreeNodeInfo.domid } - api.saveTree(params).then(data => { - if (data.status === '1') { + + api.deleteTree(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { message.success(i18n.message.deleteSuccess()); this.getTree(() => { - this.treeConfig.selectedKeys = ['-1']; + this.treeConfig.selectedKeys = ['1']; this.selectedTreeNodeInfo = this.treeConfig.data[0]; this.getTabInfoByTreeNode(null, true); }); // this.treeConfig.selectedKeys = [this.treeConfig.data[0].key]; // this.selectedTreeNodeInfo = this.treeConfig.data[0]; // this.getTabInfoByTreeNode(null, true); - } else - message.error(data.message); - }, error => { + } else { + message.warning(data.msg); + } + }).catch(error => { message.error(i18n.message.actionError()); - }); + }) + + } }); } @action("保存子信息维护") doSaveChildInfoSetting = () => { - debugger this.recordOP(this.editTable['childInfoSetting'], 'valid'); let infoNameArr = [], infoArr = []; @@ -1814,9 +1822,6 @@ export class FieldDefinedStore extends HrmBaseStore { }) } const params = { - // data: JSON.stringify({ - // records: this.convertAttr(cloneTree) - // }), data: JSON.stringify(infoArr), parentId } From ed990bcfb20ad59f1a2909bec1c28b7eebe9fd3e Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 20 Jun 2022 11:08:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E6=88=90v1.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/fieldDefined.js | 11 ++++- pc4mobx/organization/stores/fieldDefined.js | 48 +++++++++------------ 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/pc4mobx/organization/apis/fieldDefined.js b/pc4mobx/organization/apis/fieldDefined.js index 155fb2a..0d550c1 100644 --- a/pc4mobx/organization/apis/fieldDefined.js +++ b/pc4mobx/organization/apis/fieldDefined.js @@ -103,7 +103,16 @@ export const deleteTree = (moduleName,params) => { }) } -export const changeGroup = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/changeGroup`, 'POST', params) +export const changeGroup = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/changeGroup`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} export const getEncryptFieldSettingForm = (params = {}) => WeaTools.callApi(`/api/encrypt/fieldsetting/getEncryptFieldSettingForm`, 'GET', params) diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index b1c4fe6..cc230f6 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-17 18:05:13 + * @LastEditTime: 2022-06-20 11:07:43 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -50,7 +50,7 @@ export class FieldDefinedStore extends HrmBaseStore { //override baseStore.tabConfig tabDef = { color: '#000000', - groupId: '', + //groupId: '', viewCondition: '1', topButtonDef: [{ comType: 'button', @@ -138,9 +138,14 @@ export class FieldDefinedStore extends HrmBaseStore { isDropBtn: true } ] - if (this.selectedTreeNodeInfo != null && this.selectedTreeNodeInfo.viewAttr != 1) { + // if (this.selectedTreeNodeInfo != null && this.selectedTreeNodeInfo.viewAttr != 1) { + // datas.splice(2, 1); + // } + + if (this.selectedTreeNodeInfo != null && !this.selectedTreeNodeInfo.addChild) { datas.splice(2, 1); } + return datas; } dropdownProps = () => ({ @@ -635,7 +640,7 @@ export class FieldDefinedStore extends HrmBaseStore { }); if (tabArr.length > 0) { this.tabConfig.tabs = [...tabArr]; - // this.setTableEditColTitle(); + //this.setTableEditColTitle(); this.setActiveTab(this.tabConfig, init ? '1' : !create ? this.tabConfig.activeTabKey : `${tabArr.length}`); // this.containerInitFinished = { // ...this.containerInitFinished, @@ -1403,8 +1408,6 @@ export class FieldDefinedStore extends HrmBaseStore { if (p.domid === this.treeConfig.selectedKeys[0]) this.selectedTreeNodeInfo = p; p.childs && p.childs.map(c => { - - console.log(this.treeConfig.selectedKeys[0]) if (c.domid === this.treeConfig.selectedKeys[0]) this.selectedTreeNodeInfo = c; }) @@ -1446,16 +1449,6 @@ export class FieldDefinedStore extends HrmBaseStore { icon: this.menuIconCollection.setting //checkAction: 'childInfoOperability' }); - - // defaultType && !this.tableEditConfig.childInfoSetting.hasGroup && t.topButtonDef.push({ - // comType: 'button', - // type: 'primary', - // onClickHandle: this.removeTypeInfo, - // label: i18n.button.delete(), - // icon: this.menuIconCollection.setting - // }) - - } else { this.tableEditConfig.childInfoSetting.showTitle = false; this.tableEditConfig.childInfoSetting.showAdd = false; @@ -1470,7 +1463,6 @@ export class FieldDefinedStore extends HrmBaseStore { } - if (this.selectedTreeNodeInfo.domid === '-1' || this.selectedTreeNodeInfo.addChild) { this.tableEditConfig.fieldDef.columns[2].com[0].options = remove(this.tableEditConfig.fieldDef.columns[1].com[0].options, (v) => v != 'upload'); } else { @@ -1853,7 +1845,7 @@ export class FieldDefinedStore extends HrmBaseStore { break; default: const groupid = e.key; - const tabInfo = this.tabConfig.tabs[findIndex(this.tabConfig.tabs, { groupid })]; + const tabInfo = this.tabConfig.tabs[findIndex(this.tabConfig.tabs, {groupid })]; let moveFieldConfirm = i18n.confirm.moveFieldConfirm().replace('{params}', tabInfo.title); this.changeGroup(moveFieldConfirm, groupid); } @@ -1880,7 +1872,7 @@ export class FieldDefinedStore extends HrmBaseStore { }) } else { Object.assign(params, { - ids: ids.join(','), + fieldids: ids.join(','), groupid }); } @@ -1895,16 +1887,18 @@ export class FieldDefinedStore extends HrmBaseStore { } @action doChangeGroup = (params) => { - api.changeGroup(this.moduleName, params).then(data => { - if (data.status === '1') { + api.changeGroup(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { message.success(i18n.message.moveSuccess()); - // if (this.moduleName.indexOf('resource') >= 0) this.getTabInfoByTreeNode(); - // else - // this.initData(); - } else - message.error(data.message); - }, error => { message.error(i18n.message.actionError()); }); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.error(i18n.message.actionError()); + }) } @observable encryptDialogVisible = false;