Commit fe92ca08 by wangcong

初始化代码

parent 473b6bc2
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# 插件示例
## 简介
本工程是GMS业务中台中写插件的样例代码。编写插件的主要场景是:产品上通过编写插件,让产品可以在所有app打开之前,做一些必要的初始化工作。 例如扩展默认的单据控件,单据动作等。
## 模块介绍
### 1. 模块名
gms-plugin-sample
### 2. 部分功能文件介绍
1. plugin.js-------- 入口文件
2. src/control -------扩展的控件内容部分
3. src/actions --------扩展动作部分
4. src/fomula -------扩展公式
5. emcon.js ---------注册清单(定义控件名,绑定控件功能,控件相关参数配置)
6. mcon.js --------- 运行期注册
### 3. 扩展流程介绍
#### 3.1 新建控件页面
在src/control 文件夹下,创建新的.vue 文件,开发扩展控件 ,列如 testplugin.vue
```
<template>
<div>
<div>这里是个测试扩展组件</div>
</div>
</template>
<script>
export default {
name: "",
data() {
return {
}
}
}
</script>
<style scoped>
</style>
```
#### 3.2 注册扩展控件
在mcon.js文件中注册扩展的控件如下,导出的billAction、billControl、formula这三个key值不能变
```
//actions
import sampleAction from './actions/sampleAction';
//control
import sampleControl from './control/testplugin.vue';
//formula
import SubColSum from './formula/SubColSum.js';
export default {
billAction: {
sampleAction
},
billControl: {
sampleControl
},
formula:{
SubColSum
}
}
```
#### 3.3 添加控件相关参数配置
在 emcon.js 文件中添加新扩展的控件配置信息,用于页面读取
```
export default {
billControl: [
{
"title": "测试扩展", //控件名称
"description":"", //控件描述
"discard": false,
"dynamicComponent":'billForm', //
"path": "资产/通用",
"value":"sampleControl", //绑定的控件,与mcon.js 中导出的控件名一致
"extends":{} //该控件配置信息的集合
}
]
}
```
### 4. 在项目中的使用( 该功能模块将作为一个依赖包,从制品库中下载下来使用 )
1. 在 solution.json 中引用,在 "@gms" 模块下添加依赖模块 gms-plugin-sample
```
"@gms":[
{
"name": "gms-plugin-sample",
"version": "latest"
}
],
```
2. 初始化项目,从制品库拉依赖
```
os-cli init dev
```
3. 终端切到该模块下,安装模块所需依赖
```
npm i
```
4. 编译该模块
```
npm run build-dev
```
5. 切换回上级项目路径下,启动项目
```
os-cli serve
```
### 5. 查看并使用扩展的组件
项目启动后,进入工作空间,在单据的界面设计页签中,可看到扩展的控件
### 用法
1. 修改package.json以及app.config.json里面的name属性,其他的不用动
2. 在src的mcon.js文件中,按照扩展规范,注册扩展的控件、动作等。
3. npm run build构建插件
4. npm publish发布插件到npm仓库
5. 项目上通过在solution文件中引用这个插件来使用插件。
{
"name": "gms-plugin-billexpand",
"type": "gms-plugin",
"title": "插件演示",
"author": "zhengjiachao",
"keywords": "gms-plugin-billexpand",
"company": "久其软件",
"version": "v0.1",
"license": "",
"description": "",
"icon":"icon-_ZSYshujuluru",
"data": {
"app": {
"component": ["dist/app.bundle.js"]
}
}
}
\ No newline at end of file
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "@gms/gms-plugin-billexpand",
"version": "0.0.4-SNAPSHOT",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"build-dev": "vue-cli-service build --mode development",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.6",
"iviewex": "^2.6.26",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"moment": "^2.29.1",
"nr.os.js": "^1.4.18",
"number-precision": "^1.5.0",
"pdfjs-dist": "^2.10.377",
"svg-sprite-loader": "^6.0.11",
"viewerjs": "^1.10.2",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"files": [
"dist",
"src",
"app.config.json"
],
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-plugin-component": "^1.1.1",
"viewerjs": "^1.10.2",
"vue-template-compiler": "^2.6.11"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
import { getUUID } from "../query-actions/util/lib";
import SelectApprovers from '../components-control/select-approvers.vue'
export default {
execute: function (bill, param) {
if (bill) {
let taskId = bill.getGlobalParam('reviewParam').taskId;
let selectedApprovers = []
window.GMS.$http.get(`/bpm/bill/selectApprover/ApproverList/${taskId}`).then((res) => {
if (res.data.code != 200) {
this.executeApproval(bill, param)
return
}
const nodeData = res.data.ApproverVo
const optionList = [...nodeData.approvers]
GMS.$hideContainer.$Modal.confirm({
width: 700,
render: (h) => {
return h(
SelectApprovers,
{
props: {
optionList,
},
on: {
'on-change': (val) => {
selectedApprovers = val
}
}
}
)
},
onOk: () => {
window.GMS.$http.post(
'/bpm/bill/selectApprover/addApprovers',
{
...nodeData,
approvers: selectedApprovers,
}
).then(() => {
this.executeApproval(bill, param)
}).catch(() => {
GMS.$hideContainer.$Message.error('选择审批人发生错误')
})
},
onCancel: () => {
}
});
}).catch(() => {
GMS.$hideContainer.$message.error('获取审批人列表失败');
})
} else {
alert('缺少参数');
}
},
executeApproval: function(bill, param) {
if (param.param.isNeedSave) {
let saveParam = {
actions: "bill.Basic.save",
afterAction: "",
confirmTitle: "",
customSaveAction: "",
noCheckCardDepressPeriod: true,
noCheckSubTable: true,
viewName: ""
}
bill.executeServerAction(saveParam, function (code, data) {
if (code === 200) {
this.approval(bill, param);
bill.setControlsSate(param["_control_name_"], "loading", false)
} else {
bill.setControlsSate(param["_control_name_"], "loading", false)
GMS.$hideContainer.$message.error("操作异常请联系管理员");
}
}.bind(this));
} else {
this.approval(bill, param);
}
},
approval: function (bill, param) {
let billId = bill.getMasterData().getValue('id');
let taskId = bill.getGlobalParam('reviewParam').taskId;
let comments = bill.getGlobalParam('reviewParam').suggestions ? bill.getGlobalParam('reviewParam').suggestions : "";
GMS.$http.post('/gms/workflow/task/completed/' + taskId + '?result=1&comments=' + comments).then(
function (response) {
if (response.status == 200 || response.statusText == 'OK') {
// console.log('审批成功');
bill.setControlsSate(param["_control_name_"], "loading", false)
GMS.$hideContainer.$Message.success('审批成功!')
if (
window.osConfig.appOpenMode &&
window.osConfig.appOpenMode == "apploader"
) {
GMS.$hideContainer.$portalAPI.emit('nros-tag-close')
GMS.$hideContainer.$portalAPI.emit(
"open-new-page", //打开一个新的页签
getUUID(),
"runner-bill-form",
{
templateName: param.param.viewName,
id: billId,
state:'readOnly'
},
{
openWay: "FUNCTAB",
title: "单据详情",
}
);
}
else {
GMS.$hideContainer.$router.push({
path: "/showInnerBillForm/" + param.param.viewName + "/" + billId
})
}
}
}.bind(this)
)
.catch(
function (error) {
bill.setControlsSate(param["_control_name_"], "loading", false)
}.bind(this)
);
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
window.GMS.vbus.$emit('approval-user-control-edit')
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
window.GMS.vbus.$emit('approval-user-control-add')
}
}
\ No newline at end of file
export default {
bill: null,
param: null,
execute: function (bill, param) {
this.bill = bill
this.param = param
if (GMS && GMS.showDetailAction) {//查看详情,则直接关闭弹出
GMS.vbus.$emit('closeModal');
return;
}
if (param) {
bill.setControlsSate(param["_control_name_"], 'enable',false);
bill.runFormulaCheckData(param.param, function (msg) {
if (msg.length == 0) {
if (param.param && param.param.hasOwnProperty('cacheData') && !param.param.cacheData) {
this.saveData(bill, param);
} else {
let obj = bill.getBuillData();
obj.billDefine = param.define;
this.execuFormula(obj, param);//点击确定,执行公式
}
} else {
GMS.$http.post(`/baseData/data/list`, {
pagination: false,
tableName: "MD_BILLSTATE_AUDIT",
code: '1',
}).then((res) => {
bill.setControlsSate(param["_control_name_"], 'enable',true);
if (res.data.rs.code == 0) {
// 给单据赋新的状态值
bill.getMasterData().setValue('BILLSTATEAUDIT',res.data.rows[0]);
}
});
GAMS.Common.messagePrompt(msg);
}
GMS.$hideContainer.$Spin.hide();
}.bind(this));
} else {
GAMS.Common.messagePrompt('缺少参数');
}
},
saveData(bill, param) {
let that = this;
let buidData = bill.getBuillData();
console.log('buidData:', buidData);
let controlArr = bill.action.filter(
(v) => v.execute == "searchBillAction"
);
let detailData = [];
let arrApi1 = [];
if (controlArr[0].param.field && controlArr[0].param.field.length > 0) {
let tableList = controlArr[0].param.field.map(v => v.targetTableName);
tableList = Array.from(new Set(tableList));
tableList.forEach(v => {
if (buidData.hasOwnProperty(v)) {
for (let i = 0; i < bill.getSubData(v).length; i++) {
let rowDataObject = bill.getSubDataRow(v, i);
let obj = rowDataObject.getValue("currentRowData");
if (obj && obj.BILLDETAILOBJ) {
let billId = obj.BILLID;
let billName = obj.BILLNAME;
let billDefine = billName.replace(/_E/ig, "").replace(/_R/ig, "").replace(/_A/ig, "");
arrApi1.push(that.searchBillObj(billDefine, billId, obj.BILLDETAILOBJ));
} else {
let billId = rowDataObject.getData().BILLID.value;
let billName = rowDataObject.getData().BILLNAME.value;
let billDefine = billName.replace(/_E/ig, "").replace(/_R/ig, "").replace(/_A/ig, "");
arrApi1.push(that.searchBillObj(billDefine, billId));
}
}
}
})
}
if (arrApi1.length > 0) {
Promise.all(arrApi1).then((list) => {
detailData = list;
that.saveAsync(buidData, detailData, param, bill);
})
} else {
that.saveAsync(buidData, detailData, param, bill);
}
},
saveAsync(buidData, detailData, param, bill) {
let postData = {
data: buidData,
detailData: detailData
}
let url = `/rbc/bill/action/saveExpenceAccount/${param.define}`;
GMS.$http.post(url, JSON.stringify(postData), {
headers: {
post: {
"Content-Type": "application/json",
}
}
}).then(
function (response) {
bill.setControlsSate(param["_control_name_"], 'enable',true);
if (response.data.code == 0) {
//存储返回回来的创建时间、修改时间
bill.getMasterData().setValue('createTime', response.data.content.billData.createTime);
bill.getMasterData().setValue('modifyTime', response.data.content.billData.modifyTime);
bill.getMasterData().setValue('recver', response.data.content.billData.recver);
bill.getMasterData().setValue('billCode', response.data.content.billData.billCode);
GMS.vbus.$emit('saveSuccess',buidData,param);
}else{
response.data.msg && GMS.vbus.$Message.error(response.data.msg);
}
}
).catch()
},
searchBillObj(billDefine, billId, BILLDETAILOBJ) {
return new Promise((resolve, reject) => {
GMS.$http.get(
`/gms/bill/${billDefine}/${billId}?withSubs=true`
).then((data) => {
let obj = BILLDETAILOBJ;
if (data.status == 200 && data.data.code == 0) {
if(!BILLDETAILOBJ){
obj = data.data.content
}
obj.recver = data.data.content&&data.data.content.recver;
}
obj.billDefine = billDefine;
resolve(obj);
}).catch((error) => {
reject(error)
})
})
},
execuFormula(buidData, param) {
let postData = {
data: buidData
}
if (!param.param.actions) {
return
}
let url = `/gms/bill/executed/${param.define}/${param.param.actions}?transmission=total`;
GMS.$http.post(url, JSON.stringify(postData), {
headers: {
post: {
"Content-Type": "application/json",
}
}
}).then(response => {
// bill.setControlsSate(param["_control_name_"], 'enable',true);
let data = response.data;
if (data.code == 0) {
GMS.vbus.$emit('cacheEcho', buidData);//正常情况回去给子表赋值
}else if(data.code == -1 && data.message){
let stringOne = data.message.split(':')[1];
let stringResult = stringOne.split(';')[0]
let msg = stringResult.split('@');
// TODO 仍需解决 包含'@'字符的非CheckBudgetControl公示报错msg 以及else分支的按钮状态问题
if(stringResult.indexOf('@') === -1){
GAMS.Common.messagePrompt(stringResult)
if (this.bill&&this.param) {
this.bill.setControlsSate(this.param["_control_name_"], 'enable',true);
}
}else{
if(msg[0]== 1 ){
GAMS.Common.messagePrompt(msg[1]);
}else{
GMS.$hideContainer.$Modal.confirm({
title: '信息提示',
content: msg[1],
onOk: () => {
GMS.vbus.$emit('cacheEcho', buidData);//正常情况回去给子表赋值
},
onCancel: () => {}
});
}
}
}
}).catch(resp=>{
// bill.setControlsSate(param["_control_name_"], 'enable',true);
console.error("cacheSaveAction:接口调用失败 resp:"+ resp)
GAMS.Common.messagePrompt('单据保存失败..');
})
}
}
import Bridge from '../components-control/util/bridge'
export default {
execute: function (bill, param) {
if (
window.osConfig.appOpenMode &&
window.osConfig.appOpenMode == "apploader"
) {
GMS.$hideContainer.$portalAPI.emit('entry-tag-close')
}
else if (Bridge.vm) {
Bridge.vm.modal_visible = false
}
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
if (param) {
let tableName = param.param.tableName
let obj = this.getCurrentRowData(bill,tableName)
bill.addSubData(tableName)
let len = this.getSubTableLength(bill,tableName) ? this.getSubTableLength(bill,tableName) - 1 : 0
this.refreshSubDataByIndex(bill, param, tableName, obj, len)
} else {
GAMS.Common.messagePrompt('缺少参数');
}
},
getCurrentRowData(bill,tableName) {
let index = bill.getSubFocus()
let currentRowData = {}
if ( index > -1) {
let rowDataObject = bill.getSubDataRow(tableName, index);
currentRowData = rowDataObject.getValue("currentRowData");
if(!this.currentRowData){
currentRowData = rowDataObject.getRawDataCopy();
}
return currentRowData;
} else {
return currentRowData;
}
},
refreshSubDataByIndex(bill, param, tableName, obj, len) {
// 避免复制其他的id,造成重复
obj.id = null
let subObj = bill.getSubDataRow(tableName, len)
let _obj = {}
let actionParam = param
let masterSubRelation =
actionParam.param && actionParam.param.masterSubRelation
? actionParam.param.masterSubRelation[subName]
: undefined;
for (const key in obj) {
this.setTableValue(subObj, masterSubRelation + "." + key, obj[key])
_obj[key] = {
value: obj[key],
readOnly: true
}
}
subObj.setValue("currentRowData", obj)
// bill.refreshSubDataRow(tableName, "", _obj, len)
// 复制增行后不跳转到第一页,即在当前页
bill.refreshSubDataRow(tableName, "", _obj)
},
getSubTableLength(bill,tableName) {
return bill.getSubData(tableName) ? bill.getSubData(tableName).length : 0;
},
setTableValue(obj, key, val) {
obj.setValue(key, val)
}
}
\ No newline at end of file
import addInfoModal from '../control/copy-bill-modal.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
component = c;
c.bill = bill;
c.selectBill = bill.curForm.name;
let obj = bill.getBuillData(param.param);
if (obj.id) {
c.billId = obj.id;
setTimeout(() => {
c.getNewBillId();
}, 1000)
c.modal_visible = true;
} else {
GAMS.Common.messagePrompt('请在单据中录入数据');
}
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
\ No newline at end of file
export default {
execute(context, param) {
// 新建单据状态设置为可编辑,单据id为空
GMS.vbus.$emit('change-form-state', {state: '', billId: null})
},
}
import _ from 'lodash'
export default {
execute(context, param) {
if(!param.billDefine || !param.billId){
context.dom.$Message.info("请配置按钮指定参数");
return;
}
context.dom.$Modal.confirm({
title: "提示",
content: "确认删除吗?",
loading: true,
onOk: () => {
this.billDeleted(context, param);
}
})
},
billDeleted(context, param) {
GMS.$http.post(
'/rbc/bill/action/deleteExpenceAccount',{
billDefine: param.billDefine,
billId: context.selects[0][param.billId],
subTableNames: _.isEmpty(param.subTableNames) ? 'BXMXZB' : param.subTableNames
}
).then((data) => {
if (data.status == 200 && data.data.code == 0) {
context.dom.$Modal.remove();
context.dom.$Message.success('删除成功');
GMS.vbus.$emit('custom-query-refresh');
GMS.vbus.$emit('tab-count-refresh');
} else {
context.dom.$Modal.remove();
context.dom.$Message.error(data.data.message);
}
})
}
}
import customSelect from '../control/CustomerSelect.vue';
export default {
execute: function (bill, param) {
if (param) {
console.log('param', param)
GMS.$hideContainer.addComponent(customSelect, {}, async function (c) {
const getExtrCondition = async (filterFieldObj) => {
let extrConditions = []
for (const key in filterFieldObj) {
let extrConditionObj = { name: filterFieldObj[key] }
let value = bill.getMasterData().getValue(key)
extrConditionObj.values = await getExtrConditionObjValue(value),
extrConditionObj.type = getExtrConditionObjType(value)
extrConditions.push(extrConditionObj)
}
return extrConditions
}
const getExtrConditionObjType = (val) => {
const type = typeof val
const reg = new RegExp(/^[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}$/)
if (Object.prototype.toString.call(val) === '[object Object]') {
const value = val.code
const type = typeof value
return type.toUpperCase()
} else if (Object.prototype.toString.call(val) === '[object Date]') {
return 'DATE'
} else if (type === 'number' || type === 'boolean') {
return type.toUpperCase()
} else if (reg.test(val)) {
return 'UUID'
} else {
return type.toUpperCase()
}
}
const getExtrConditionObjValue = async (val) => {
if (Object.prototype.toString.call(val) === '[object Object]') {
if (val._type) {
const tableName = val._type.split('.').length > 0 ? val._type.split('.')[1] : val._type
const postData = {
pagination: false,
tableName: tableName,
searchKey: "",
queryDataStructure: "ALL",
queryChildrenType: "ALL_CHILDREN_WITH_SELF",
code: val.code,
authType: "ACCESS",
versionDate: "",
expression: "",
}
const {data} = await GMS.$http.post(`/baseData/data/list`, postData)
const node = data.rows[0]
const value = node.objectcode? node.objectcode: val.code
return value
} else {
return val.objectcode? val.objectcode: val.code
}
} else {
return val
}
}
c.bill = bill
const actionParam = param.param
c.field = actionParam.field
c.baseDataFields = actionParam.field.baseDataFields
c.templateName = actionParam.templateName
c.tableName = actionParam.tableName
c.extrCondition = await getExtrCondition(actionParam.field.filterField)
c.isDrawer = true
c.drawerShow = true
c.actionParam = actionParam
// let isSub = actionParam.tableName.split('.').length
let isSub = false
c.isSub = isSub === 1
})
} else {
GAMS.Common.messagePrompt('缺少参数');
}
},
}
\ No newline at end of file
export default {
execute(bill, param) {
GMS.$hideContainer.$Modal.confirm({
title: "提示",
content: "确认删除吗?",
loading: true,
onOk: () => {
this.billDeleted(bill, param);
}
})
},
billDeleted(bill, param) {
GMS.$http.post(
'/rbc/bill/action/deleteExpenceAccount', {
billDefine: bill.getBillDefine(),
billId: bill.getMasterData().getValue('id'),
subTableNames: param.subTableNames? param.subTableNames: 'BXMXZB'
}
).then((data) => {
if (data.status == 200 && data.data.code == 0) {
GMS.$hideContainer.$Modal.remove();
GMS.$hideContainer.$Message.success('删除成功');
GMS.vbus.$emit('change-form-state', {state: '', billId: null})
} else {
GMS.$hideContainer.$Modal.remove();
GMS.$hideContainer.$Message.error(data.data.message);
}
})
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
const curbill = bill.dom || bill
// bill.deleteSubData(param.param.tableName,bill.getSubFocus(),true)
const imageTable = curbill.getSubData(param.param.tableName)
const imageTableObj = imageTable[curbill.getSubFocus()]
const imageId = imageTableObj.getValue('imageId')
const targetSubTable = curbill.getSubData(param.param.targetTableName)
if (targetSubTable instanceof Array) {
for (let i = targetSubTable.length - 1; i >= 0; --i) {
const tableObj = targetSubTable[i]
const invoiceId = tableObj.getValue('imageId')
if (invoiceId == imageId) {
curbill.deleteSubData(param.param.targetTableName, i, true)
}
}
}
curbill.deleteSubData(param.param.tableName, curbill.getSubFocus(), true)
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
GMS.$hideContainer.$Modal.confirm({
title: '提示',
content: '确认删除吗?',
onOk: () => {
this.delete(bill, param)
},
onCancel: () => {
GMS.$hideContainer.$Message['error']({
content: '已取消',
});
}
});
},
delete (bill,param) {
if(bill){
if(param.param.customDeleteDyAction){
this.customAction(bill, param,param.param.customDeleteDyAction);
}else if(param.param.customDeleteAction){
param['_actionParam'] = param.param.customDeleteAction;
this.customAction(bill, param,param.param.customDeleteAction.action);
}else{
bill.deleteSubData(param.param.tableName,bill.getSubFocus(),true);
}
}else{
alert('缺少参数');
}
}
}
\ No newline at end of file
/**
* 修改草稿线上bug
* 将数据库中所有的草稿json数据重置屏蔽字段
* @author fengjiansheng
* @date 2022-01-11
*/
export default {
execute: function (bill, param) {
GMS.$hideContainer.$Modal.confirm({
title: '提示',
content: '确认是否扫库(请做好备份 GMS_BILLDATA_DRAFT)',
onOk: () => {
this.fixBug()
},
onCancel: () => {
GMS.$hideContainer.$Message['error']({
content: '已取消',
});
}
});
},
fixBug() {
GMS.$http.post('/rbcfunc/billdraft/fixBug', null).then(res => {
GMS.$hideContainer.$Message.success('重置数据成功');
}).catch(resp => {
GMS.$hideContainer.$Message.success('重置数据失败,请联系管理员');
console.log(resp)
})
}
}
import draftName from '../control/draftName.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let columns = []
let children = [];
let name = GMS.$hideContainer.addComponent(draftName, {}, function (c) {
component = c;
c.bill = bill;
c.data = bill.getBuillData(param.param);
let ignoreTempFields = 'id,billCode,billState,flowState,BILLSTATEAUDIT,'
if ('ignoreFields' in param.param && param.param.ignoreFields.length > 0) {
ignoreTempFields += param.param.ignoreFields
}
Object.keys(c.data).forEach(e => {
if (Array.isArray(c.data[e])) {
for (let i = 0; i < c.data[e].length; i++) {
let obj = c.data[e][i]
if (ignoreTempFields && ignoreTempFields.length > 0) {
ignoreTempFields.split(',').forEach(temp1 => {
if (temp1 in obj) {
c.data[e][i][temp1] = undefined
}
})
}
}
}
}
);
if (ignoreTempFields && ignoreTempFields.length > 0) {
ignoreTempFields.split(',').forEach(e => {
if (e in c.data) {
c.data[e] = undefined
}
})
}
c.billDefineName = bill.curForm.content.billdefine;
c.draftModal = true;
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
import customSelect from '../control/draftTable.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let columns = []
let children = []
let name = GMS.$hideContainer.addComponent(customSelect, {}, function (c) {
component = c;
c.bill = bill;
c.drawerShow = true;
c.getList();
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
\ No newline at end of file
import addInfoModal from '../components-control/add-info-modal.vue';
export default {
execute: function (bill, param) {
if (param) {
delete GMS.editSubIndex;
let component = null;
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
component = c;
c.bill = bill;
let arr = bill.action.filter(v=>v.execute=="searchBillAction");
let tableName = null;
if(arr.length>0){
c.actionParam = arr[0];
tableName = arr[0].param.field[0].targetTableName;
}
if(param.param && param.param.tableName){
tableName = param.param.tableName
}
let obj = c.getCurrentRowData(tableName);
if(!obj['BILLNAME']){
GAMS.Common.messagePrompt('缺少参数');
return
}
c.selectBill = obj['BILLEDITNAME'];
c.billId = obj['BILLID'];
c.subBillData = obj.BILLDETAILOBJ;
c.modal_visible = true;
GMS.editSubIndex = bill.getSubFocus();
console.log('param',param,obj);
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
// 编辑单据状态设置为可编辑,单据id不传
GMS.vbus.$emit('change-form-state', { state: ''})
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
let dataObject = bill.getMasterData();
let id = dataObject.getValue('id');
let rq = dataObject.getValue('RQ');
let djlb = dataObject.getValue('DJLB').code;
GMS.$http.post(`/rbc/bill/action/extractCash`, {
id:id,
date:rq,
djlb:djlb
}).then((res) => {
if(res.data.code===0){
this.setSubTableData(bill,'RIMXZZB',res.data.content)
}else if(res.data.code == -1 && res.data.message){
GAMS.Common.messagePrompt(res.data.message);
}
})
},
setSubTableData(bill,tableName,datas) {
//清空子表
let subData = bill.getSubData(tableName)
let dataLength = subData.length
if (dataLength > 0) {
for (let i = 0; i < dataLength; i++) {
bill.deleteSubData(tableName, 0,null)
}
}
//子表字段
let subField = this.getSubField(bill,tableName)
let allFormula = null
//赋值子表
datas.forEach((data, index) => {
const subData = bill.addSubData(tableName,index)
for (const key in subField) {
if(key == 'BZ' || key == 'DJLB' || key == 'BXBM' || key == 'SFKR'){
const idKey = key + 'ID'
const codeKey = key + 'CODE'
const nameKey = key + 'NAME'
const baseDataValue = { id: data[idKey],code:data[codeKey], name: data[nameKey] }
subData.setValue(key, baseDataValue)
}else if(key == 'RQ'){
subData.setValue(key, new Date(data[key]).getTime())
}else{
subData.setValue(key, data[key])
}
}
//调用子表公式
if (!allFormula) {
allFormula = bill.getSubFormula(tableName)
}
this.funSubTableFormula(bill,allFormula.execution[tableName])
})
bill.refreshSubDataRow(tableName)
if (datas.length > 0) {
GMS.vbus.$Message.success('提取成功');
} else {
GMS.vbus.$Message.success('没有数据');
}
},
getSubField(bill,tableName) {
let fieldObj = {}
if (bill.getAllSubFiledByName(tableName)) {
fieldObj = JSON.parse(JSON.stringify(bill.getAllSubFiledByName(tableName)))
} else {
this.$message.error('子表字段获取失败')
}
return fieldObj
},
funSubTableFormula(bill,formuals){
var subFormulaList = this.getSubFormulas(formuals);
if(subFormulaList&&subFormulaList.length > 0){
for (const _s_f_n of subFormulaList) {
bill.runSubSumFormula(_s_f_n);
}
}
},
getSubFormulas(formuals){
var subFormulaList = [];
for (const _f in formuals) {
for (const iterator of formuals[_f]) {
subFormulaList.push(iterator);
}
}
return Array.from(new Set(subFormulaList));
}
}
\ No newline at end of file
import ImageViewModal from '../../../../@rbc/invoice/src/components/image-view-modal/image-view-modal.vue'
export default {
execute: function (bill, param) {
const curbill = bill.dom || bill
// const billCode = 'e7bb5a4e-9028-4475-9164-a268725a7faa'
GMS.$hideContainer.addComponent(ImageViewModal, {}, function (c) {
c.imageTableName = param.param.tableName
c.bill = curbill
})
// if (param) {
// GMS.$hideContainer.addComponent(ImageViewModal, {}, function (c) {
// c.billId = bill.getMasterData().getValue('id');
// })
// } else {
// GAMS.Common.messagePrompt('缺少参数')
// }
}
}
\ No newline at end of file
import addInfoModal from '../components-control/add-info-modal.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
component = c;
c.bill = bill;
c.actionParam = param;
c.getAssetsModal();
c.detailItem=param.param.subTableName;
let arr=bill.getGlobalParam(`__gms__${c.detailItem}__`);
arr.map(a => {
if (a.type != 'ACTION') {
a.control = GMS.getContext().getCollector().getElement('billControl', a.valueType);
a.config.field = a.field;
a.define = {
config: a.config,
layout: {},
name: a.valueType,
type: a.valueType,
};
}
});
c.tableColnum = arr.filter(a => a.type != 'ACTION')
c.currentRowData = {};
c.modal_visible = true;
c.$nextTick(function () {
component.addListener({
close: function () {
GMS.$hideContainer.remove(name);
}
});
});
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
bill.executeServerAction(param.param, function(code, data) {
this.clearListener(bill, param);
if (code === 200) {
GMS.vbus.$emit('saveEcho', bill.getBuillData(),param);
GMS.vbus.$Message.success(param.param.successMssage || "保存成功");
} else if (code === 201) {
GMS.vbus.$Message.error(data.message);
} else if (code === 202) {
if (data.responseJSON.message && data.responseJSON.message.startsWith("FLOW-")) {
GMS.vbus.$Message.error({
content: data.responseJSON.message,
duration: 3
});
} else {
GMS.vbus.$Message.error("创建单据异常请联系管理员");
}
}
}.bind(this));
},
clearListener(bill, param){
bill.changeLoadingStatus(param.define, false);
GMS.$hideContainer.$Spin.hide();
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
if (param) {
let buidData = bill.getBuillData();
// GMS.$hideContainer.$router.push({
// path: "/editBillForm/" + param.param.viewName + "/" + buidData.id
// });
GMS.vbus.$emit('openEditBillForm', buidData,param);
}
}
}
\ No newline at end of file
import { compareData } from "../components-control/util/dataChange.js";
export default {
execute(bill, param) {
// 首张、上张、下张、末张
let flag =
GMS.queryObject && GMS.queryObject.isReadOnly
? true
: compareData(GMS.oldBillData, bill.getBuillData());
if (flag) {
if (Object.keys(param.param).length > 0) {
this.getOtherPage(Object.keys(param.param)[0]);
}
} else {
GMS.$hideContainer.$Modal.confirm({
title: "信息提示",
content: "信息发生变化,确认切换?",
onOk: () => {
if (Object.keys(param.param).length > 0) {
this.getOtherPage(Object.keys(param.param)[0]);
}
},
onCancel: () => {
GMS.$hideContainer.$Message["info"]({
content: "已取消",
});
},
});
}
},
async getOtherPage(action) {
let page = GMS.queryObject.currentDataQueryConditionSet.page;
let index =
GMS.queryObject.index == -1
? GMS.queryObject.index
: (page.pageNum - 1) * page.size + GMS.queryObject.index;
const url = `/rbc/bill/move/${action.toUpperCase()}/${index}`;
const { data } = await window.GMS.$http.post(
url,
GMS.queryObject.currentDataQueryConditionSet
);
if (data) {
console.log(data.data.id);
if (data.data && data.data.id) {
if (action == "down") {
GMS.queryObject.index++;
} else if (action == "upward") {
GMS.queryObject.index--;
} else if (action == "first") {
GMS.queryObject.index = 0;
} else if (action == "last") {
GMS.queryObject.index = data.data.count - 1;
}
if (
window.osConfig.appOpenMode &&
window.osConfig.appOpenMode == "apploader"
) {
GMS.$hideContainer.$portalAPI.emit("resetBillData", data.data.id);
} else {
GMS.vbus.$emit("resetBillData", data.data.id);
}
}
if (data.data && data.data.message) {
GMS.vbus.$Message.info(data.data.message);
}
}
},
};
import printBill from '../control/printBill.vue'
export default {
execute: function (bill, param) {
if (param) {
GMS.$hideContainer.addComponent(printBill, {}, function (c) {
c.billId = bill.getMasterData().getValue('id');
c.billDefineName = param.define;
if(param.param.subName){
c.subName = param.param.subName;
}
c.modalShow = true;
})
} else {
GAMS.Common.messagePrompt('缺少参数')
}
}
}
\ No newline at end of file
import printBill from '../control/printBill.vue'
export default {
execute: function (bill, param) {
if (param) {
GMS.$hideContainer.addComponent(printBill, {}, function (c) {
c.billId = bill.getMasterData().getValue('id');
c.billDefineName = param.define;
if(param.param.subName){
c.subName = param.param.subName;
}
c.modalShow = true;
})
} else {
GAMS.Common.messagePrompt('缺少参数')
}
}
}
\ No newline at end of file
import printBill from '../control/printBill.vue'
export default {
execute: function (bill, param) {
if (param) {
GMS.$hideContainer.addComponent(printBill, {}, function (c) {
if(param.param.detailFieldName){
let url = `/rbcfunc/print/merge/multi/${param.define}/${bill.getMasterData().getValue('id')}/${param.param.detailFieldName}?detailName=BXMXZB`;
GMS.$http
.post(url, JSON.stringify(), {
responseType: "blob",
headers: {
"Content-Type": "application/pdf;charset=utf-8",
"X-Requested-With": "XMLHttpRequest",
},
})
.then((res) => {
let blob = new Blob([res.data], {
type: "application/pdf;charset=utf-8",
}); let downloadElement = document.createElement("a");
let href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
window.open(href)
});
}else{
c.billId = bill.getMasterData().getValue('id');
c.billDefineName = param.define;
if(param.param.subName){
c.subName = param.param.subName;
}
c.modalShow = true;
}
})
} else {
GAMS.Common.messagePrompt('缺少参数')
}
}
}
\ No newline at end of file
import { getUUID } from "../query-actions/util/lib";
export default {
execute: function (bill, param) {
if(bill){
if(param.param.isNeedSave){
let saveParam = {
actions: "bill.Basic.save",
afterAction: "",
confirmTitle: "",
customSaveAction: "",
noCheckCardDepressPeriod: true,
noCheckSubTable: true,
viewName: ""
}
bill.executeServerAction(saveParam,function(code,data){
if(code===200){
this.approval(bill, param);
bill.setControlsSate(param["_control_name_"],"loading",false)
}else{
bill.setControlsSate(param["_control_name_"],"loading",false)
GMS.$hideContainer.$message.error("操作异常请联系管理员");
}
}.bind(this));
} else {
this.approval(bill, param);
}
}else{
alert('缺少参数');
}
},
approval: function(bill, param){
let billId = bill.getMasterData().getValue('id');
let taskId = bill.getGlobalParam('reviewParam').taskId;
let comments = bill.getGlobalParam('reviewParam').suggestions ? bill.getGlobalParam('reviewParam').suggestions:"";
GMS.$http.post('/gms/workflow/task/completed/' + taskId + '?result=3&comments='+comments).then(
function(response) {
if (response.status == 200 || response.statusText == 'OK') {
// console.log('驳回成功');
bill.setControlsSate(param["_control_name_"],"loading",false)
GMS.$hideContainer.$Message.success('驳回成功!')
if (
window.osConfig.appOpenMode &&
window.osConfig.appOpenMode == "apploader"
) {
GMS.$hideContainer.$portalAPI.emit('nros-tag-close')
GMS.$hideContainer.$portalAPI.emit(
"open-new-page", //打开一个新的页签
getUUID(),
"runner-bill-form",
{
templateName: param.param.viewName,
id: billId,
state:'readOnly'
},
{
openWay: "FUNCTAB",
title: "单据详情",
}
);
}
else {
GMS.$hideContainer.$router.push({
path: "/showInnerBillForm/" + param.param.viewName + "/" + billId
})
}
}
}.bind(this)
)
.catch(
function(error) {
bill.setControlsSate(param["_control_name_"],"loading",false)
}.bind(this)
);
}
}
\ No newline at end of file
import InvoiceModal from '../components-control/invoice-modal.vue'
export default {
execute: function (bill, param) {
GMS.$hideContainer.addComponent(InvoiceModal, {}, function (c) {
c.bill = bill.dom
c.invoiceName = param.param.invoiceName
})
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
alert("sample action")
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
if (bill) {
bill.runFormulaCheckData(param, function (msg) {
if (msg.length == 0) {
let postData = {
actions: "bill.Basic.save"
}
bill.setControlsSate(param["_control_name_"], 'enable', false)
bill.executeServerAction(postData, function (code, data) {
bill.setControlsSate(param["_control_name_"], 'enable', true)
if (code === 200) {
const id = data.content.billData.id
GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id})
GMS.vbus.$Message.success("保存成功");
} else if (code === 201) {
GMS.vbus.$Message.error(data.message);
} else if (code === 202) {
if (data.responseJSON.message && data.responseJSON.message.startsWith("FLOW-")) {
GMS.vbus.$Message.error({
content: data.responseJSON.message,
duration: 3
});
} else {
GMS.vbus.$Message.error("保存单据异常请联系管理员");
}
}
})
} else {
GMS.vbus.$Modal.warning({
title: '信息错误',
content: msg
});
}
})
}
}
}
\ No newline at end of file
import addInfoModal from '../components-control/add-info-modal.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
component = c;
c.masterFieldsObj={};
if(param.param && param.param.masterFields){
param.param.masterFields.forEach(v=>{
v.fieldBillRelation.forEach(item=>{
if(item.targetField){
c.masterFieldsObj[item.targetField] = bill.getMasterData().getValue(item.targetField);
}
})
})
}
c.bill = bill;
c.actionParam = param;
c.actionParam.param.viewArr.map(v=>v.title=v.title.split('[')[0])
c.getAssetsModal();
c.currentRowData = {};
c.selectBill='';
c.modal_visible = true;
c.$nextTick(function () {
component.addListener({
close: function () {
GMS.$hideContainer.remove(name);
}
});
});
});
} else {
GAMS.Common.messagePrompt('缺少参数');
}
}
}
\ No newline at end of file
import selectQueryAction from '../control/selectQueryView.vue';
export default {
execute: function (bill, param) {
if (param) {
GMS.$hideContainer.addComponent(selectQueryAction, {}, async function (c) {
debugger
const getExtrCondition = async (filterFieldObj) => {
let extrConditions = []
for (const key in filterFieldObj) {
let extrConditionObj = { name: filterFieldObj[key] }
let value = bill.getMasterData().getValue(key)
extrConditionObj.values = await getExtrConditionObjValue(value),
extrConditionObj.type = getExtrConditionObjType(value)
console.log('type', await getExtrConditionObjType(value))
extrConditions.push(extrConditionObj)
}
return extrConditions
}
const getExtrConditionObjType = (val) => {
const type = typeof val
const reg = new RegExp(/^[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}$/)
if (Object.prototype.toString.call(val) === '[object Object]') {
const value = val.code
const type = typeof value
return type.toUpperCase()
} else if (Object.prototype.toString.call(val) === '[object Date]') {
return 'DATE'
} else if (type === 'number' || type === 'boolean') {
return type.toUpperCase()
} else if (reg.test(val)) {
return 'UUID'
} else {
return type.toUpperCase()
}
}
const getExtrConditionObjValue = async (val) => {
if (Object.prototype.toString.call(val) === '[object Object]') {
if (val._type) {
const tableName = val._type.split('.').length > 0 ? val._type.split('.')[1] : val._type
const postData = {
pagination: false,
tableName: tableName,
searchKey: "",
queryDataStructure: "ALL",
queryChildrenType: "ALL_CHILDREN_WITH_SELF",
code: val.code,
authType: "ACCESS",
versionDate: "",
expression: "",
}
const {data} = await GMS.$http.post(`/baseData/data/list`, postData)
console.log('res.data', data)
const node = data.rows[0]
const value = node.objectcode? node.objectcode: val.code
return value
} else {
return val.objectcode? val.objectcode: val.code
}
} else {
return val
}
}
c.bill = bill
const actionParam = param.param
c.field = actionParam.field
c.baseDataFields = actionParam.field.baseDataFields
c.templateName = actionParam.templateName
c.tableName = actionParam.tableName
const res = await getExtrCondition(actionParam.field.filterField)
c.extrCondition = res
c.isDrawer = true
c.drawerShow = true
console.log('extrCondition', c.extrCondition)
let isSub = actionParam.tableName.split('.').length
c.isSub = isSub === 1
})
} else {
GAMS.Common.messagePrompt('缺少参数');
}
},
}
\ No newline at end of file
import addInfoModal from '../components-control/add-info-modal.vue';
export default {
execute: function (bill, param) {
if (param) {
let component = null;
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
GMS.showDetailAction = true;//详情,点击确定按钮。记录此参数
component = c;
c.bill = bill;
c.isReadOnly = true
let tableName = null;
if(param.param && param.param.tableName){
tableName = param.param.tableName
}
let obj = c.getCurrentRowData(tableName);
if(!obj['BILLNAME']&&tableName=='SRMXZB'){
GAMS.Common.messagePrompt('此条数据没有详情信息');
return
}
if(!obj['BILLNAME']){
GAMS.Common.messagePrompt('无详情参数');
return
}
c.showDetail = true;
c.selectBill = obj['BILLEDITNAME'].replace(/_E/ig, "_R");//后续创建了_R的单子再说吧
//c.selectBill = obj['BILLEDITNAME'];
c.billId = obj['BILLID'];
c.subBillData = obj.BILLDETAILOBJ;
c.modal_visible = true;
console.log('param',param,obj);
});
} else {
GAMS.Common.messagePrompt('无详情参数');
}
}
}
\ No newline at end of file
import { getUUID } from "../query-actions/util/lib";
export default {
execute: function (bill, param) {
let postData = {
updatebillState: "2",
actions: "workflow.submitToFlow"
}
if (bill) {
bill.setControlsSate(param["_control_name_"], 'enable', false)
// GMS.$hideContainer.$Spin.show();
bill.executeServerAction(postData, function (code, data) {
bill.setControlsSate(param["_control_name_"], 'enable', true)
if (code === 200) {
// GMS.$hideContainer.$Spin.hide();
const id = data.content.billData.id
GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id})
GMS.$hideContainer.$Message.success('提交成功');
if (
window.osConfig.appOpenMode &&
window.osConfig.appOpenMode == "apploader"
) {
GMS.$hideContainer.$portalAPI.emit('nros-tag-close')
GMS.$hideContainer.$portalAPI.emit(
"open-new-page", //打开一个新的页签
getUUID(),
"runner-bill-form",
{
templateName: param.param.viewName,
id,
state:'readOnly'
},
{
openWay: "FUNCTAB",
title: "单据详情",
}
);
}
else {
GMS.$hideContainer.$router.push({
path: "/showInnerBillForm/" + param.param.viewName + "/" + billId
})
}
} else if (code === 201) {
GMS.$hideContainer.$Spin.hide();
GMS.$hideContainer.$Message.error("提交失败");
} else if (code === 202) {
GMS.$hideContainer.$Spin.hide();
GMS.$hideContainer.$Message.error("暂存单据异常请联系管理员");
}
}.bind(this));
} else {
GMS.$hideContainer.$Spin.hide();
alert('缺少参数');
}
}
}
\ No newline at end of file
export default {
execute: function (bill, param) {
if (bill) {
let postData = {
actions: "bill.Basic.quickSave"
}
bill.setControlsSate(param["_control_name_"], 'enable',false)
bill.executeServerAction(postData, function (code, data) {
bill.setControlsSate(param["_control_name_"], 'enable',true)
if (code === 200) {
const id = data.content.billData.id
GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id})
GMS.$hideContainer.$Message.success('暂存成功');
} else if (code === 201) {
GMS.$hideContainer.$Message.error(data.message);
} else if (code === 202) {
GMS.$hideContainer.$Message.error("暂存单据异常请联系管理员");
}
})
}
}
}
\ No newline at end of file
/*
* @Author: rao JiaGuan
* @Date: 2021年12月2日17:06:21
* @LastEditors: rao JiaGuan
* @Description: 林草项目状态修改
*/
export default {
execute: function(bill, param) {
let msg;
if(param.param.clickMessage){
msg = param.param.clickMessage
}
GMS.$hideContainer.$Modal.confirm({
title: "信息提示",
content: msg,
onOk: () => {
this.updateFieldAction(bill, param);
},
onCancel: () => {
GMS.$hideContainer.$Message["error"]({
content: "已取消",
});
},
});
},
updateFieldAction(bill, param) {
debugger
let _actions = param.param.actions;
let define = param.define;
let postData = {
data: bill.getBuillData(),
};
let url = `/gms/bill/executed/${define}/${_actions}?transmission=total`;
GMS.$http
.post(url, postData, {
headers: {
post: {
"Content-Type": "application/json",
},
},
})
.then((res) => {
if (res.status == 200 && res.data.code == 0) {
const masterName = bill.billdata.billTable.masterName;
let successMessage;
if(param.param.successMessage){
successMessage = param.param.successMessage
}
GMS.vbus.$Message.success(successMessage);
// 刷新页面
GMS.vbus.$emit("custom-query-refresh");
GMS.vbus.$emit("tab-count-refresh");
GMS.vbus.$emit("submitSuccess");
} else if (res.data.code == -1 && res.data.message) {
let stringOne = res.data.message.split(":")[1];
let stringResult = stringOne.split(";")[0];
GMS.vbus.$Message.error(stringResult);
} else {
res.data.message && GMS.vbus.$Message.error(res.data.message);
}
});
},
};
\ No newline at end of file
/*
* @Author: shi ZongLiang
* @Date: 2021-06-25 14:19:32
* @LastEditors: shi ZongLiang
* @Description: 更改状态值
*/
export default {
execute: function(bill, param) {
debugger
const masterName = bill.billdata.billTable.masterName;
let msg;
if (param.param.updatebillState == 2 && masterName == "CNSFK_H") {
msg = "确认出纳当前信息?";
} else if (param.param.updatebillState == 2 && masterName != "CNSFK_H") {
msg = "确认提交当前信息?";
} else if (param.param.updatebillState == 3) {
msg = "确认同意当前信息?";
} else if (param.param.updatebillState == 4) {
msg = "确认驳回当前信息?";
}
GMS.$hideContainer.$Modal.confirm({
title: "信息提示",
content: msg,
onOk: () => {
if (param.param && param.param.budgetcontrol) {
let res = this.getBudgetControl(bill, true, param);
res.then((data) => {
if (data.code == 0) {
let result = this.getBudgetControl(bill, false, param);
result.then((data1) => {
if (data1.code == 0) {
this.updateBillState(bill, param);
} else if (data1.code == 1) {
GAMS.Common.messagePrompt(data1.msg);
}
});
} else if (data.code == 1) {
setTimeout(() => {
GAMS.Common.messagePrompt(data.msg);
}, 500);
} else if (data.code == 2) {
setTimeout(() => {
this.getModal(bill, param, data);
}, 500);
}
});
} else {
this.updateBillState(bill, param);
}
},
onCancel: () => {
GMS.$hideContainer.$Message["error"]({
content: "已取消",
});
},
});
},
getModal(bill, param, data) {
GMS.$hideContainer.$Modal.confirm({
title: "信息提示",
content: data.msg,
onOk: () => {
let result = this.getBudgetControl(bill, false, param);
result.then((data1) => {
if (data1.code == 0) {
this.updateBillState(bill, param);
} else if (data1.code == 1) {
GAMS.Common.messagePrompt(data1.msg);
}
});
},
onCancel: () => {
GMS.$hideContainer.$Message["error"]({
content: "已取消",
});
},
});
},
getBudgetControl(bill, check, param) {
let postData = {
data: bill.getBuillData(),
};
let url = `/v1/budget/control/${param.define}/${check}`;
return new Promise((resolve, reject) => {
GMS.$http
.post(url, postData, {
headers: {
post: {
"Content-Type": "application/json",
},
},
})
.then((res) => {
resolve(res.data);
});
});
},
updateBillState(bill, param) {
let _actions = param.param.actions;
let define = param.define;
let postData = {
data: bill.getBuillData(),
};
let url = `/gms/bill/executed/${define}/${_actions}?transmission=total`;
GMS.$http
.post(url, postData, {
headers: {
post: {
"Content-Type": "application/json",
},
},
})
.then((res) => {
if (res.status == 200 && res.data.code == 0) {
const masterName = bill.billdata.billTable.masterName;
if (param.param.updatebillState == 2 && masterName == "CNSFK_H") {
GMS.vbus.$Message.success("出纳成功");
} else if (
param.param.updatebillState == 2 &&
masterName != "CNSFK_H"
) {
GMS.vbus.$Message.success("提交成功");
} else if (param.param.updatebillState == 3) {
GMS.vbus.$Message.success("审批同意");
} else if (param.param.updatebillState == 4) {
GMS.vbus.$Message.success("驳回成功");
}
// 刷新页面
GMS.vbus.$emit("custom-query-refresh");
GMS.vbus.$emit("tab-count-refresh");
GMS.vbus.$emit("submitSuccess");
} else if (res.data.code == -1 && res.data.message) {
let stringOne = res.data.message.split(":")[1];
let stringResult = stringOne.split(";")[0];
GMS.vbus.$Message.error(stringResult);
} else {
res.data.message && GMS.vbus.$Message.error(res.data.message);
}
});
},
};
<template>
<div>
<Modal v-model="modalShow" title="单据列表" :width="600">
<div class="card-container">
<div class="card" v-for="item in billList" :key="item.value" @click="handleCardClick(item.value)">
<Card>
<h3>{{item.title}}</h3>
</Card>
</div>
</div>
</Modal>
<typeBill ref="billRef"></typeBill>
</div>
</template>
<script>
import typeBill from './typesBill.vue'
export default {
components: {
typeBill,
},
props: {
billList: Array,
},
data() {
return {
modalShow: false,
}
},
methods: {
handleCardClick(val) {
this.$refs.billRef.modal_visible = true
this.$refs.billRef.templateName = val
this.$refs.billRef.init = true
this.$refs.billRef.state = ''
this.$nextTick(() => {
this.modalShow = false
})
},
},
}
</script>
<style scoped lang="less">
.card-container {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
cursor: pointer;
.card {
margin-bottom: 10px;
/deep/ .ivu-card {
h3 {
height: 21px;
width: 130px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
</style>
<template>
<Modal class-name="relate-invoice-modal" v-model="modalVisible" fullscreen title="引用票据" @on-ok="handleOk">
<InvoiceList :mode="1" @selectionChange="handleSelectionChange" />
</Modal>
</template>
<script>
import InvoiceList from '../../../../@rbc/invoice/src/components/invoice-list.vue'
export default {
components: {
InvoiceList,
},
data() {
return {
selectedRows: [],
modalVisible: true,
bill: null,
invoiceName: '',
}
},
methods: {
handleSelectionChange(rows) {
this.selectedRows = rows
},
handleOk() {
if (!this.selectedRows) {
this.$Message.error('请选择数据')
}
if (this.selectedRows.some((row) => !row.frontendVerificationStatus)) {
this.$Message.error('部分数据需先查验成功方可选择')
}
for (let i = 0; i < this.selectedRows.length; ++i) {
const row = this.selectedRows[i]
let templateName = this.invoiceName.split('.')[1]
templateName = `${templateName}.res.json`
GMS.$http.post(
'/yxgl/getImageAndInvoiceMappingRelation',
{
imageId: row.id,
templateName: templateName,
yearFlag: row.yearFlag,
},
).then((res) => {
const arr = res && res.data && res.data.data || []
arr.forEach((tableMap) => {
const mapContent = tableMap.content
const subBillName = tableMap.subBillName
this.bill.addSubData(subBillName)
const obj = this.bill.getSubData(subBillName)
const index = obj.length - 1
for (let key of Object.keys(mapContent)) {
const keyVal = mapContent[key]
obj[index].setValue(key, keyVal)
}
this.bill.refreshSubDataRow(subBillName)
})
})
}
},
},
}
</script>
<style lang="less">
.relate-invoice-modal {
.ivu-modal-body {
padding: 0;
}
}
</style>
\ No newline at end of file
<template>
<div class="news-container">
<div class="news-detail">
<div class="detail-title">{{title}}</div>
<div class="detail-description">摘要:{{description}} &nbsp&nbsp&nbsp&nbsp 时间:{{time}}</div>
<div class="detail-content" v-html="content"></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
title: '',
description: '',
content: '',
time: ''
}
},
mounted() {
const { title, description, content, time } = this.$route.query
this.title = title
this.description = description
this.content = content
this.time = time
},
}
</script>
<style scoped lang="less">
.news-container {
width: 100%;
height: 100%;
background: #ccc;
overflow: hidden;
.news-detail {
width: 55%;
margin: 50px auto 50px auto;
height: calc(100% - 100px);
background: #fff;
padding: 10px;
border-radius: 5px;
box-shadow: blue;
box-shadow: 4px 2px #cccccc;
.detail-title {
height: 40px;
line-height: 40px;
font-size: 30px;
font-weight: 600;
text-align: center;
border-bottom: soild #333;
border-bottom: 1px solid #ccc;
padding-bottom: 10px;
box-sizing: content-box;
margin-top: 10px;
}
.detail-description {
height: 30px;
line-height: 30px;
font-size: 14px;
text-align: center;
border-bottom: 1px solid #ccc;
margin-top: 10px;
margin-bottom: 5px;
}
}
}
</style>
<template>
<div class="select-approvers">
<div class="title">选择下一步审批人</div>
<Input
size="small"
v-model="searchInput"
suffix="ios-search"
style="width: 100%; margin: 10px 0px 5px 0px;"
/>
<Table
size="small"
border
ref="selection"
:max-height="450"
:columns="columns"
:data="filteredData"
@on-selection-change="handleSelectionChange"
></Table>
</div>
</template>
<script>
export default {
props: {
optionList: {
default: () => [],
type: Array,
}
},
data() {
return {
searchInput: '',
columns: [
{
type: 'selection',
width: 60,
align: 'center'
},
{
title: '姓名',
key: 'nickname'
},
{
title: '组织机构',
key: 'orgTitle'
},
{
title: '部门',
key: 'departmentName'
}
],
}
},
watch: {
optionList: {
immediate: true,
handler(val) {
this.filterData(this.searchInput)
}
},
searchInput(val) {
this.filterData()
}
},
methods: {
filterData() {
this.$refs.selection && this.$refs.selection.selectAll(false)
if (!!this.searchInput) {
this.filteredData = this.optionList.filter((o) => {
return o.nickname.includes(this.searchInput)
})
}
else {
this.filteredData = [...this.optionList]
}
},
handleSelectionChange(selection) {
this.$emit('on-change', selection.map((o) => o.userid))
}
}
}
</script>
<style lang="less" scoped>
.select-approvers {
width: 100%;
height: 100%;
.title {
font-size: 14px;
font-weight: 500;
}
/deep/ .ivu-table-small {
/deep/ .ivu-table-header {
table thead tr th {
padding: 2px 0px;
}
}
/deep/ .ivu-table-body {
td {
padding: 5px 0px;
/deep/ .ivu-table-cell {
padding: 1px 10px;
}
}
}
}
}
</style>
\ No newline at end of file
<template>
<div>
<iframe :src="pdfUrl" frameborder="0" style="width: 100%; height: calc(100vh - 50px)"></iframe>
<div class="btn">
<Button @click="handleCancel" class="btnInner">关闭</Button>
</div>
</div>
</template>
<script>
export default {
props: {},
data() {
return {
pdfUrl:''
}
},
watch: {
},
methods: {
handleCancel(){
window.close();
}
},
mounted() {
this.pdfUrl=this.$route.query.src;
},
}
</script>
<style scoped lang="less">
.btn{
position:fixed;
bottom:0px;
right:0px;
height:50px;
left:0;
}
.btnInner{
position:absolute;
right:20px;
bottom:10px
}
</style>
<template>
<div class="openModal" v-if="modal_visible">
<Modal
v-model="modal_visible"
:title="' '"
:mask-closable="false"
:fullscreen="true"
:class-name="'initHeight'"
>
<p slot="header">
<a class="ivu-modal-close" @click="handleCancel">
<Icon type="ios-close"
/></a>
</p>
<gms-bill-form
:templateName="templateName"
:id="billId"
:type="billId ? 'load' : 'init'"
:state="state"
@loadFinish="loadFinishFun"
v-if="init"
></gms-bill-form>
<div slot="footer" style="height: 0"></div>
</Modal>
</div>
</template>
<script>
import { compareData } from "./util/dataChange.js";
import Bridge from "./util/bridge.js";
export default {
props: {},
data() {
return {
init: false,
modal_visible: false,
templateName: null,
billId: null,
state: null,
isReadOnly: false,
billClass: null,
oldBillData: null,
};
},
watch: {
templateName: {
handler(newVal, oldVal) {
this.templateName = newVal;
},
},
},
methods: {
changeData(billId) {
this.init = false;
this.$nextTick(() => {
this.billId = billId;
this.init = true;
});
},
loadFinishFun(bill) {
let that = this;
setTimeout(() => {
that.billClass = bill;
GMS.oldBillData = bill.getBuillData();
that.oldBillData = bill.getBuillData();
}, 100);
},
handleCancel() {
//关闭弹出,刷新列表
let newBill = this.isReadOnly
? this.oldBillData
: this.billClass.getBuillData();
let flag = compareData(this.oldBillData, newBill);
if (flag) {
delete GMS.editSubIndex;
GMS.vbus.$off("cacheEcho");
GMS.vbus.$emit("custom-query-refresh");
GMS.vbus.$emit("tab-count-refresh");
this.modal_visible = false;
} else {
//提示是否保存
this.$Modal.confirm({
title: "信息提示",
content: "信息发生变化,确认关闭?",
onOk: () => {
this.modal_visible = false;
},
onCancel: () => {
this.modal_visible = true;
},
});
}
},
initBill(res, param, isSave) {
this.billId = res.id;
//this.state = "readOnly";
if (
res.BILLSTATEAUDIT &&
res.BILLSTATEAUDIT.code == 2 &&
param.param.approveViewName
) {
//审核成功,
this.templateName = param.param.approveViewName;
} else if (param.param.viewName) {
this.templateName = param.param.viewName;
}
if (isSave) {
this.state = "readOnly";
}
this.init = false;
this.$nextTick(() => {
this.init = true;
});
},
},
created() {
GMS.vbus.$off("saveSuccess");
},
mounted() {
Bridge.vm = this;
GMS.vbus.$on("change-form-state", (param) => {
const { state, billId } = param;
if (billId !== undefined) {
this.billId = billId;
}
this.state = state;
this.init = false;
this.$nextTick(() => {
this.init = true;
});
});
GMS.vbus.$on("submitSuccess", (res, param) => {
GMS.vbus.$emit("custom-query-refresh");
GMS.vbus.$emit("tab-count-refresh");
this.modal_visible = false;
});
GMS.vbus.$on("openEditBillForm", (res, param) => {
//详情界面点击修改按钮
this.isReadOnly = false;
this.initBill(res, param);
});
GMS.vbus.$on("saveEcho", (res, param) => {
this.initBill(res, param);
});
GMS.vbus.$on("saveSuccess", (res, param) => {
//自己扩展的保存
GMS.vbus.$Message.success("保存成功");
this.initBill(res, param, true);
});
GMS.vbus.$on("resetBillData", this.changeData);
},
beforeDestroy() {
delete GMS.editSubIndex;
GMS.vbus.$off("cacheEcho");
GMS.vbus.$off("openEditBillForm");
GMS.vbus.$off("saveSuccess");
GMS.vbus.$off("submitSuccess");
GMS.vbus.$off("change-form-state");
},
};
</script>
<style scoped lang="less">
.openModal {
.ivu-modal-close .ivu-icon-ios-close {
font-size: 31px;
color: #999;
-webkit-transition: color 0.2s ease;
transition: color 0.2s ease;
position: relative;
top: 1px;
}
}
</style>
class Bridge {
static vm = null
constructor(vm) {
this.vm = vm
}
getVM() {
return this.vm
}
}
\ No newline at end of file
function convertDate(date) {
if (typeof date === "number") {
return date;
} else if (typeof date != "object" && new Date(date).getTime()) {
return new Date(date).getTime();
} else {
return date;
}
}
export function compareData(oldBillData, newBill) {
let that = this;
for (let i in oldBillData) {
if (i.endsWith("RQ") || i.endsWith("Time") || i.endsWith("SJ")) {
oldBillData[i] = convertDate(oldBillData[i]);
}
if (
Object.prototype.toString.apply(oldBillData[i]) == "[object Object]" &&
oldBillData[i].code
) {
//处理基础数据类型
let code = oldBillData[i].code;
oldBillData[i] = {};
oldBillData[i].code = code;
}
if (
i.endsWith("ZB") &&
Object.prototype.toString.apply(oldBillData[i]) == "[object Array]" &&
oldBillData[i].length > 0
) {
let dateArr = Object.keys(oldBillData[i][0]).filter(
//处理子表中的日期
(v) => v.endsWith("RQ") || v.endsWith("Time") || v.endsWith("SJ")
);
oldBillData[i].forEach((v) => {
if (dateArr.length > 0) {
dateArr.forEach((b) => {
v[b] = convertDate(v[b]);
});
}
Object.entries(v).forEach((k) => {
if (
Object.prototype.toString.apply(k[1]) == "[object Object]" &&
k[1].code
) {
let code = k[1].code;
v[k[0]] = {};
v[k[0]].code = code;
}
});
});
}
}
for (let i in newBill) {
if (i.endsWith("RQ") || i.endsWith("Time") || i.endsWith("SJ")) {
newBill[i] = convertDate(newBill[i]);
}
if (
Object.prototype.toString.apply(newBill[i]) == "[object Object]" &&
newBill[i].code
) {
//处理基础数据类型
let code = newBill[i].code;
newBill[i] = {};
newBill[i].code = code;
}
if (
i.endsWith("ZB") &&
Object.prototype.toString.apply(newBill[i]) == "[object Array]" &&
newBill[i].length > 0
) {
let dateArr = Object.keys(newBill[i][0]).filter(
(v) => v.endsWith("RQ") || v.endsWith("Time") || v.endsWith("SJ")
);
//处理子表中的日期
newBill[i].forEach((v) => {
if (dateArr.length > 0) {
dateArr.forEach((b) => {
v[b] = convertDate(v[b]);
});
}
Object.entries(v).forEach((k) => {
if (
Object.prototype.toString.apply(k[1]) == "[object Object]" &&
k[1].code
) {
let code = k[1].code;
v[k[0]] = {};
v[k[0]].code = code;
}
});
});
}
}
return JSON.stringify(oldBillData) == JSON.stringify(newBill);
}
<template>
<div>
<Drawer v-if="isDrawer" v-model="drawerShow" width="900" :mask-closable="false">
<gms-query v-if="templateName" class="gms-query" :templateName="templateName" :extrCondition="extrCondition"></gms-query>
<div class="drawer-footer">
<Button style="margin-right: 8px" @click="drawerShow = false">取消</Button>
<Button type="primary" :disabled="queryData.length === 0" @click="handleConfirm">确定</Button>
</div>
</Drawer>
</div>
</template>
<script>
export default {
name: 'CustomerSelect',
props: {
context: {
type: Object,
default: () => {},
},
},
data() {
return {
bill: {},
drawerShow: false,
templateName: '',
queryData: [],
tableName: '',
isSub: true,
field: {},
baseDataFields: [],
extrCondition: [],
isDrawer: false,
actionParam: null
}
},
mounted() {
GMS.vbus.$on('onSelectionChange', (selection) => {
this.queryData = [...selection]
})
GMS.vbus.$on('onCurrentChange', (currentRow) => {
this.queryData = [currentRow]
})
},
methods: {
handleConfirm() {
if (!this.tableName) {
this.$message.error('操作表名称为空')
return
}
if (this.isSub) {
// this.queryData = [
// { x: 1, y: 2 },
// { x: 3, y: 4 },
// ]
this.queryData.forEach((item, index) => {
this.setSubTableData(item, index)
})
// 刷新
this.bill.refreshSubDataRow(this.tableName)
} else {
this.setMasterData()
}
this.drawerShow = false
},
setSubTableData(sourceRow, index) {
// 增行
this.bill.addSubData(this.tableName)
//赋值
const subDataObj = this.bill.getSubData(this.tableName)
const tableLength = subDataObj.length || 0
const subDataIndex = tableLength - 1
const subRowData = this.getRowData(sourceRow)
if (Array.isArray(subDataObj)) {
for (const key in subRowData) {
if (this.baseDataFields&&this.baseDataFields.includes(key)) {
const idKey = this.field[key] + 'id'
const baseDataValue = { id: sourceRow[idKey], name: subRowData[key].value }
console.log('baseDataValue', baseDataValue)
subDataObj[subDataIndex].setValue(key, baseDataValue)
} else {
subDataObj[subDataIndex].setValue(key, subRowData[key].value)
}
}
}
},
getRowData(sourceRow) {
let subField = this.getSubField()
// this.field = {
// a1: 'x',
// b1: 'y',
// }
console.log('field', this.field)
for (let key in this.field) {
if(key !== 'baseDataFields' && key !== 'filterField') {
subField[key].value = sourceRow[this.field[key]]
subField[key].readOnly = subField.hasOwnProperty(key)
}
}
return subField
},
setMasterData() {
let masterName = this.tableName.split('.')[1]
let keys = Object.keys(this.field)
keys.forEach((key) => {
let value = ''
let str = masterName + '.' + key
for (let k in this.queryData[0]) {
if (k === this.field[key]) {
value = this.queryData[0][this.field[key]]
}
}
this.bill.getMasterData().setValue(str, value)
})
this.bill.runFormulaCheckData(this.actionParam, function(msg){})
},
getSubField() {
let fieldObj = {}
if (this.bill.getAllSubFiledByName(this.tableName)) {
fieldObj = JSON.parse(JSON.stringify(this.bill.getAllSubFiledByName(this.tableName)))
} else {
this.$message.error('子表字段获取失败')
}
return fieldObj
},
},
}
</script>
<style lang="less" scoped>
.gms-query.customQueryBody {
padding-top: 40px;
/deep/ .tabChangeBody {
overflow: scroll;
.spaceLine {
height: 0;
margin-top: 0;
}
.seniorQueryBody{
margin-top: 30px;
}
.ivu-select-dropdown {
top: -110px !important;
left: -500px !important;
}
}
}
.drawer-footer {
width: 100%;
position: absolute;
bottom: 0;
left: 0;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
background: #fff;
}
</style>
\ No newline at end of file
<template>
<div>
<Modal v-model="modal_visible" :title="context.moadlTitle" @on-cancel="handleCancel" :closable="true" :mask-closable="false"
width="960" @on-visible-change="onVisibleChange">
<Form ref="subTableEntity" :model="subTableEntity" :rules="ruleValidate" :label-width="130">
<Row :gutter="24">
<Col span="12" v-for="(item,index) in context.tableColnum" :key="index">
<FormItem :label="item.title" prop="commonName" class="required-edit">
<component :is="item.control" :id="index" :define="item.define" :key="index" :context="context"></component>
</FormItem>
</Col>
</Row>
</Form>
<div slot="footer">
<Button @click="handleCancel">取消</Button>
<Button @click="handleAddAssetsSave" v-if="!isEdit">添加</Button>
<Button @click="handleAddAssetsSave" v-if="isEdit">确定</Button>
<Button @click="handleSaveAndNext" type="primary">继续添加</Button>
</div>
</Modal>
</div>
</template>
<script>
export default {
props: {
readOnly: {
type: Boolean,
default: false
},
context: {
type: Object
}
},
data() {
return {
isEdit: '',
ruleValidate: {
},
modal_visible: true,
subTableEntity: {},
detailItem: null,
currentRow: null,
}
},
watch: {
},
methods: {
handleCancel() {
this.modal_visible = false;
},
onVisibleChange() {},
handleSaveAndNext() {
let detailItem=this.context.detailItem;
this.context.tableColnum.forEach(a => {
let b = a.field.split(".")[1];
this.subTableEntity[b] = this.context.dataObject.getValue(a.field);
})
this.$refs['subTableEntity'].validate((valid) => {
if (valid) {
let obj = JSON.parse(JSON.stringify(this.subTableEntity));
if (this.isEdit) {
this.context.refreshSubDataByIndex(detailItem, obj, this.context.getCurrentIndex());
this.isEdit = false;
} else {
this.context.addSubTableRow(detailItem);
this.context.refreshSubDataByIndex(detailItem, obj, this.context.getSubTableLength(detailItem) - 1);
}
this.$refs["subTableEntity"].resetFields();
}
})
},
handleAddAssetsSave() {
let detailItem=this.context.detailItem;
this.context.tableColnum.forEach(a => {
let subTableEntity = a.field.split(".")[0];
let b = a.field.split(".")[1];
this.subTableEntity[b] = this.context.dataObject.getValue(a.field);
})
this.$refs['subTableEntity'].validate(function(valid) {
if (valid) {
console.log('subTableEntity',this.context.actionParam,detailItem,this.context.actionParam.param.masterSubRelation[detailItem]);
if (this.isEdit) {
this.context.refreshSubDataByIndex(detailItem, this.subTableEntity, this.context.getCurrentIndex());
this.isEdit = false;
} else {
// 点击保存先去新建一行然后去将弹窗页面的数据跟新到新建的这一行中
if (Object.keys(this.currentRow).length == 0) {
this.context.addSubTableRow(detailItem);
}
this.context.refreshSubDataByIndex(detailItem, this.subTableEntity, this.context.getSubTableLength(
detailItem) ?
this.context.getSubTableLength(detailItem) - 1 : 0);
}
this.modal_visible = false;
}
}.bind(this));
},
},
mounted() {
this.context.initModal();
this.context.dataObject = this.context.bill.getMasterData();
this.currentRow = this.context.getCurrentRowData(this.context.detailItem);
if (this.currentRow) {
for (let s in this.currentRow) {
this.context.dataObject.setValue(s, this.currentRow[s]);
}
}
this.isEdit = this.context.getSubTableStatus();
if (this.isEdit) {
this.subTableEntity = this.context.getRowDataByIndex(this.context.detailItem, this.context.getCurrentIndex());
}
}
}
</script>
<style scoped lang="less">
.inputSize {
width: 100%;
}
/deep/.required-edit {
/deep/.ivu-form-item-label:before {
content: '*';
display: inline-block;
margin-right: 4px;
line-height: 1;
font-family: SimSun;
font-size: 12px;
color: #ED664B;
}
}
</style>
<template>
<el-popover
trigger="manual"
:value="value"
ref="popover"
>
<div
style="display: flex; align-items: center; justify-content: center; margin: 4px 4px 12px 4px;"
><Icon style="color: #FF9D00;" type="ios-help-circle" /><span>确定要删除本条意见吗?</span></div>
<div style="text-align: right; margin: 0">
<Button size="small" type="text" @click="$emit('cancle')">取消</Button>
<Button type="primary" size="small" @click="$emit('confirm')">确定</Button>
</div>
<template slot="reference"><slot></slot></template>
</el-popover>
</template>
<script>
export default {
props: ['value'],
}
</script>
<style>
</style>
\ No newline at end of file
export default {
props: {
value: {
type: [Object, Array, String, Number],
required: false,
},
title: {
type: String,
default: '基础数据选择',
},
multiple: {
type: Boolean,
default: false,
},
clearable: {
type: Boolean,
default: true,
},
disabled: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: '',
},
maxTagCount: {
type: Number,
},
tableKey: {
type: String,
default: () => 'id',
},
treeKey: {
type: String,
default: () => 'id',
},
searchPlaceholder: {
type: String,
default: '',
},
tableName: {
type: String,
required: true
},
/**
* 组织机构权限类型,默认访问权限
*/
authType: {
type: String,
default: 'ACCESS',
},
/**
* 版本日期, 格式 9999-12-31
*/
versionDate: {
type: String,
default: '',
},
modalWidth: {
type: [Number, String],
default: 970,
},
inputLabel: {
type: String,
default: 'name',
validator: (value) => {
return value === 'code' || value === 'name' || value === 'codeName'
},
},
isLeaf: {
type: Boolean,
default: false
},
filterFormular: {
type: String,
default: ''
},
filterFormularSP: {
type: String,
default: ''
},
billdefineName: {
type: String,
default: ''
},
billId: {
type: String,
default: ''
},
isFilter: {
type: Boolean,
default: false
},
bill: {
type: Object,
default: () => { }
},
defineObject: {
type: Object,
default: () => {}
},
rowIndex: {
type: Number,
default: -1
},
isCode: {
type: Boolean,
default: false
},
isObject: {
type: Boolean,
default: false
},
tableStyle: {
type: Boolean,
default: false
},
groupTableName: {
type: Object,
default: () => ({
tableName:'',
groupFieldName:'',
define:''
})
},
structtype: {
type: Number,
default: -1
},
treeTableName: {
type: String,
default: ''
},
hideSelected: {
type: Boolean,
default: false
}
},
data () {
return {
tempFilterFormular: '', // 临时公式,方便处理,不然直接修改props会有问题
removeMasterListener: null,
removeSubListener: null
}
},
watch: {
filterFormular: {
handler(val) {
this.tempFilterFormular = val;
},
immediate: true
}
},
computed: {
isOrg() {
return this.tableName === 'MD_ORG'
},
},
beforeDestroy () {
this.removeMasterListener && this.removeMasterListener()
this.removeSubListener && this.removeSubListener()
},
methods: {
async getOrg(param) {
let result = await GMS.$http
.post('/org/data/list', param)
.then((res) => {
const { rows, rs } = res.data
return rows
})
.catch((err) => {
console.error('获取组织机构失败:' + JSON.stringify(err))
console.log('error', err)
})
return result
},
handleFormular () {
if (this.filterFormular && Object.keys(this.bill).length > 0) {
let reg = this.filterFormular.match(/\s[A-Za-z]\w*\.[A-Za-z]\w*\s*(?=\=)/)
if (!reg) {
return
}
let changeKey = reg[0].trim()
let oldChangeKey = ''
let currentFiledList = this.defineObject.field.split('.') // 当前要过滤的字段
let catchFiledList = changeKey.split('.') // 条件字段
let initValue = this.bill.getMasterData().getValue(changeKey) // 初始的时候的替换真实的值
initValue = this.handleNv(initValue)
this.tempFilterFormular = this.filterFormular.replace(changeKey, initValue)
oldChangeKey = initValue
if (this.bill.getTableType(currentFiledList[0]).type === 'sub' && this.bill.getTableType(catchFiledList[0]).type === 'sub') {
this.$Message.warning('暂不支持子表关联子表!')
return
}
if (this.bill.getTableType(catchFiledList[0]).type === 'sub') {
let that = this
that.removeSubListener = this.bill.addSubDataChangeListenr("detailList", {
changeSubDataValue: function (value, index, key) {
if (key === changeKey) {
const newChangeKey = that.handleNv(value)
that.tempFilterFormular = that.tempFilterFormular.replace(oldChangeKey, newChangeKey)
oldChangeKey = newChangeKey
if (that.getBaseDataList) {
that.getBaseDataList()
}
}
}
})
} else if (this.bill.getTableType(catchFiledList[0]).type === 'master') {
this.removeMasterListener = this.bill.getMasterData().addListener(changeKey, {
valueChange: function (nv, ov) {
const newChangeKey = this.handleNv(nv)
this.tempFilterFormular = this.tempFilterFormular.replace(oldChangeKey, newChangeKey)
oldChangeKey = newChangeKey
if (this.getBaseDataList) {
this.getBaseDataList()
}
// 替换然后查询
}.bind(this)
})
}
}
},
handleNv (nv) {
let newChangeKey = null
if (Object.prototype.toString.call(nv) === '[object Object]') {
newChangeKey = nv.code
} else {
switch (typeof nv) {
case 'string':
if(isNaN(nv)&&!isNaN(Date.parse(nv))){
newChangeKey = Date(nv)
} else {
newChangeKey = nv.replace(/\"/, '\"')
}
break
case 'number':
newChangeKey = nv
break
default:
newChangeKey = nv
break
}
}
newChangeKey = `\"${newChangeKey}\"`
return newChangeKey
},
getBaseData(postData, urlParam, isInit = false) {
let url = ''
let postParam = {}
if (this.isFilter && !isInit) {
let newParam = {}
if (this.bill && this.bill.getBuillData) {
delete postData.expression
delete postData['BI-SYNTAX']
const getParamBill = () => {
let bill = this.bill.getBuillData && this.bill.getBuillData()
if (bill&&bill.id) {
bill.id = this.billId
}
return bill
}
newParam = {
baseDataDto: postData,
filterFormular: this.filterFormularSP,
billdefineName: this.billdefineName,
billId: this.billId,
bill: getParamBill(),
rowIndex: this.rowIndex
}
}
url = urlParam || `/rbcfunc/baseData/list`
if (urlParam) {
postParam = JSON.parse(JSON.stringify(postData))
} else {
postParam = JSON.parse(JSON.stringify(newParam))
}
} else {
url = urlParam || `/baseData/data/list`
postParam = JSON.parse(JSON.stringify(postData))
}
return GMS.$http
.post(url, JSON.stringify(postParam), {
headers: {
post: {
'Content-Type': 'application/json',
},
},
})
},
}
}
.input-height /deep/ .ivu-input-default {
height: 100%;
}
.input-center /deep/ .ivu-input-default {
text-align: center;
}
.input-left /deep/ .ivu-input-default {
text-align: left;
}
.input-right /deep/ .ivu-input-default {
text-align: right;
}
.input-control-wrapper {
display: inline-block;
width: 100%;
position: relative;
}
.input-height{
/deep/.ivu-input-default{
height: 100%;
}
}
.input-center{
/deep/.ivu-input-default{
text-align: center;
}
}
.input-left{
/deep/.ivu-input-default{
text-align: left;
}
}
.input-right{
/deep/.ivu-input-default{
text-align: right;
}
}
.input-control-wrapper{
display: inline-block;
width: 100%;
position: relative;
}
\ No newline at end of file
<style lang="less" scoped>
.modal {
background: #f5f7f9;
width: 100%;
height: 430px;
// height: 550px;
overflow: hidden;
&-left {
float: left;
top: 0;
width: 220px;
height: 100%;
background: white;
}
&-right {
float: left;
top: 0;
margin-left: 5px;
width: calc(~'100% - 225px');
height: 100%;
background: white;
}
}
</style>
<template>
<div class="dept-person-div">
<Modal
v-model="visible"
:title="title"
:width="modalWidth"
@on-ok="onOk"
@on-cancel="onCancel"
>
<div class="modal" :style="{height: modalHeight}">
<div class="modal-left">
<Tree
ref="_tree"
style="width:100%; height: 100%"
:table-name="tableName"
:primaryKey="treeKey"
:authType="authType"
:versionDate="versionDate"
:groupTableName="groupTableName"
:treeTableName="treeTableName"
:filterList="filterList"
:structtype="structtype"
:filterFormular="filterFormular"
:filterFormularSP="filterFormularSP"
:billdefineName="billdefineName"
:billId="billId"
:bill="bill"
:isFilter="isFilter"
:rowIndex="rowIndex"
@on-select="onTreeSelected"
@init-tree="onInitTree"
/>
</div>
<div class="modal-right">
<SelectTable
ref="_view"
:treeNode="currTreeNode"
:value="selection"
:table-name="tableName"
:primaryKey="tableKey"
:treeKey="treeKey"
:tableColumns="tableColumns"
:searchPlaceholder="searchPlaceholder"
:multiple="multiple"
:authType="authType"
:versionDate="versionDate"
:isLeaf="isLeaf"
:structtype="structtype"
:groupTableName="groupTableName"
:treeDataMap="treeDataMap"
:groupFieldName="groupFieldName"
:hideSelected="hideSelected"
:filterFormular="filterFormular"
:filterFormularSP="filterFormularSP"
:billdefineName="billdefineName"
:billId="billId"
:bill="bill"
:isFilter="isFilter"
:rowIndex="rowIndex"
@init-list="onInitList"
/>
</div>
</div>
</Modal>
</div>
</template>
<script>
import Tree from './tree.vue'
import SelectTable from './select-table.vue'
import baseDataMixin from './baseDataMixin'
export default {
mixins: [baseDataMixin],
components: { Tree, SelectTable },
props: {
value: {
type: Boolean,
required: true,
},
selection: {
type: Array,
default: () => [],
},
tableColumns: {
type: Array,
require: true,
}
},
computed: {
visible: {
set: function (val) {
this.$emit('input', val)
},
get: function () {
return this.value
},
},
},
data() {
return {
currTreeNode: null,
treeDataMap: {},
groupFieldName: '',
modalHeight: '430px',
filterList: []
}
},
mounted() {
this.getModalHeight()
window.onresize = () => {
this.getModalHeight()
}
},
methods: {
getModalHeight() {
let viewport = window.innerHeight
if (viewport <= 600 && viewport >= 400) {
this.modalHeight = Math.floor(viewport/2) + 'px'
} else if (viewport < 400) {
this.modalHeight = '200px'
} else {
this.modalHeight = '430px'
}
},
onOk() {
let result = this.$refs._view.save()
this.visible = false
this.$emit('on-ok', result)
},
onCancel() {
this.visible = false
this.$emit('on-cancel')
},
onTreeSelected(id, item) {
this.currTreeNode = item
},
onInitTree(treeDataMap, groupFieldName) {
this.treeDataMap = JSON.parse(JSON.stringify(treeDataMap))
this.groupFieldName = groupFieldName
},
onInitList(filterList) {
if(this.filterList.length === 0) {
this.filterList = JSON.parse(JSON.stringify(filterList))
}
}
},
}
</script>
\ No newline at end of file
export default {
computed: {
tagValue: {
get: function () {
if (this.multiple) {
return this.selection
} else {
return 0 == this.selection.length ? null : this.selection[0]
}
},
},
},
watch: {
value: {
handler: function (newVal) {
if (newVal) {
this.init(newVal)
} else {
this.selection = []
this.sendEvent(null)
}
},
deep: true,
},
},
methods: {
init(value) {
if (this.multiple) {
let codes = []
if (this.isCode) {
if(value&&value[0] instanceof Object) {
codes = value.map((item) => item.code.toString())
} else {
codes = value.map(item => item.toString())
}
} else {
codes = value.map((item) => item.code.toString())
}
if(this.setSelection) {
this.initBySelection(codes, this.setSelection)
} else {
this.initBySelection(codes)
}
} else {
let code = ''
if (this.isCode) {
if(value instanceof Object) {
code = value.code.toString()
} else {
code = value.toString()
}
} else {
code = value.code?value.code.toString():value.toString()
}
if(this.setSelection) {
this.initBySelection(code, this.setSelection)
} else {
this.initBySelection(code)
}
}
},
async initBySelection(code, callback) {
if (this.isOrg) {
let param = {
pagination: false,
queryDataStructure: 'ALL',
}
if (this.multiple) {
param.orgCodes = code
} else {
param.code = code
}
this.selection = await this.getOrg(param)
} else {
let postData = {
tableName: this.tableName,
searchKey: '',
queryDataStructure: 'ALL',
authType: this.authType,
versionDate: this.versionDate,
expression: this.filterFormular,
'BI-SYNTAX': null
}
if (this.multiple) {
postData.baseDataCodes = code
} else {
postData.code = code
}
this.getBaseData(postData, '', true)
.then((response) => {
const { rows, rs, total } = response.data
this.selection = rows
// 这段代码会影响到回显右侧表格的勾选
// if(this.isCode &&rows&&rows[0]){
// this.selectedValue = rows[0].code
// }else if(rows&&rows[0]){
// this.selectedValue = rows[0]
// this.selectedValue.id = rows[0].code;
// this.selectedValue.text = rows[0].name;
// }
// let result = this.getReturnInfo()
// this.sendEvent(result)
if (callback) {
callback(rows)
}
})
.catch((XMLHttpRequest) => {
this.$Message.error('信息获取失败')
})
}
},
getReturnInfo() {
if (this.multiple) {
if (this.isCode) {
return this.selection.map(item => item.code)
} else {
return this.selection
}
} else {
if (this.isCode) {
return 0 == this.selection.length ? null : this.selection[0].code
} else {
return 0 == this.selection.length ? null : this.selection[0]
}
}
},
sendEvent(result) {
this.$emit('input', result)
this.$emit('data-change', result)
// this.dispatch && this.dispatch('FormItem', 'on-form-change', result)
},
}
}
\ No newline at end of file
<style lang="less" scoped>
.option-group {
width: 100%;
height: 100%;
overflow: hidden;
font-size: .75rem;
.option-group-data {
width: 100%;
height: 100%;
overflow: auto;
}
.option {
width: 100%;
float: left;
min-height: 30px;
}
.option-title {
width: calc(~'100% - 24px');
float: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.option-title-span {
width: calc(~'100% - 5px');
float: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.option-checkbox {
float: left;
width: 20px;
margin-right: 4px;
}
}
</style>
<template>
<div class="option-group">
<div
v-if="hasData"
class="option-group-data"
>
<div
class="option"
v-for="(item, index) in data"
:key="item.code"
>
<div class="option-checkbox">
<Checkbox
:value="item._checked"
@on-change="selectCancel(item)"
/>
</div>
<div class="option-title">
<Tooltip :content="showTitle(item, index)">
<span class="option-title-span">{{showTitle(item, index)}}</span>
</Tooltip>
</div>
<div style="clear:both"></div>
</div>
</div>
<div
class="no-data"
v-else
>
{{"暂无数据"}}
</div>
</div>
</template>
<script>
export default {
props: {
data: {
type: Array,
default: () => [],
},
},
computed: {
hasData: {
get: function () {
return this.data && this.data.length > 0
},
},
},
methods: {
showTitle(item, index) {
return item.name + '(' + item.code + ')'
},
selectCancel(item) {
this.$emit('on-change', item)
},
},
}
</script>
\ No newline at end of file
<style lang="less" scoped>
.view-div {
width: 100%;
height: 100%;
padding: 10px 0 0 10px;
.selected-view {
width: 150px;
height: 100%;
float: left;
font-size: .75rem;
}
.selected-view-content {
width: 100%;
height: calc(~'100% - 38px');
}
.table-view {
width: calc(~'100% - 160px');
margin-left: 10px;
height: 100%;
float: left;
}
.table-view-noselected{
width: calc(~'100% - 10px')
}
}
</style>
<template>
<div class="view-div">
<div v-show="!hideSelected" class="selected-view" >
<div style="margin-bottom: 20px; width: 100%;">
<Checkbox
:value="selection.length > 0"
:disabled="selection.length == 0"
@on-change="allCancel"
/>
{{"已选(" + selection.length + ")条"}}
</div>
<div class="selected-view-content">
<SelectedView
:data="selection"
@on-change="onCancelSelected"
/>
</div>
</div>
<div class="table-view " :class="{'table-view-noselected': hideSelected}">
<TableView
ref="_tableView"
:primaryKey="primaryKey"
:columns="tableColumns"
:data="tableDatas"
:pageTotal="pageTotal"
:pageSize="pageSize"
:selection="selection"
:multiple="multiple"
:loading="loading"
:isLeaf="isLeaf"
:treeDataMap="treeDataMap"
:structtype="structtype"
:canSwitchMode="false"
:searchPlaceholder="searchPlaceholder"
@on-page-change="onPageChange"
@on-select="onSelect"
@on-select-cancel="onSelectCancel"
@on-select-all="onSelectAll"
@on-select-all-cancel="onSelectAllCancel"
@on-search-enter="onSearchEnter"
/>
</div>
</div>
</template>
<script>
import TableView from './table-view'
import SelectedView from './option-group'
import baseDataMixin from './baseDataMixin'
export default {
mixins: [baseDataMixin],
data() {
return {
pageTotal: 0,
pageSize: 20,
pageNo: 1,
total: 0,
tableDatas: [],
selection: [],
searchInfo: '', // 模糊搜索信息
justSelected: false, // 查看模式
loading: false,
}
},
props: {
treeDataMap: {
type: Object
},
groupFieldName: {
type: String
},
treeNode: {
type: Object,
required: false,
},
value: {
type: Array,
required: false,
},
primaryKey: {
type: String,
required: true,
},
tableColumns: {
type: Array,
require: true,
},
},
watch: {
treeNode: {
handler: function (newVal, oldVal) {
if (newVal && oldVal && newVal[this.treeKey] == oldVal[this.treeKey]) {
return
}
this.pageNo = 1
this.refresh(newVal)
},
deep: true,
},
value: {
handler: function (newVal) {
this.selection = JSON.parse(JSON.stringify(newVal))
this.selection.map((item) => {
item._checked = true
})
this.refreshRowsCheckStatus(newVal, this.tableDatas)
},
deep: true,
},
},
components: {
TableView,
SelectedView,
},
mounted() {
this.selection = this.value ? JSON.parse(JSON.stringify(this.value)) : []
this.selection.map((item) => {
item._checked = true
})
this.loading = true
this.resize()
},
methods: {
save() {
let _selection = JSON.parse(JSON.stringify(this.selection))
return _selection
},
resize() {
this.$refs._tableView &&
this.$refs._tableView.resize &&
this.$refs._tableView.resize()
},
refresh(treeNode) {
if (!treeNode) {
this.tableDatas = []
return
}
this.refreshWhenAll(treeNode)
},
async refreshWhenAll(treeNode) {
if (this.isOrg) {
let param = {
pagination: true,
parentcode: treeNode.code,
searchKey: this.searchInfo,
queryDataStructure: 'ALL',
limit: this.pageSize,
offset: (this.pageNo - 1) * this.pageSize,
}
GMS.$http
.post('/org/data/list', param)
.then((res) => {
const { rows, rs, total } = res.data
this.pageTotal = total
let _tabledatas = rows
this.refreshRowsCheckStatus(this.selection, _tabledatas)
this.tableDatas = _tabledatas
this.loading = false
})
.catch((err) => {
console.error('获取组织机构失败:' + JSON.stringify(err))
console.log('error', err)
})
} else {
let that = this
this.loading = true
// 更新右侧table
let postData = {}
if (this.structtype === 1) {
const treeData = JSON.parse(JSON.stringify(this.treeNode))
treeData.children = this.treeDataMap[this.treeNode.code]
let objectCodes = []
const getGroupNames = (nodes) => {
nodes.forEach(item => {
if (item && item.attributes && item.attributes.objectcode) {
objectCodes.push(item.attributes.objectcode)
}
if (item.children && item.children.length > 0) {
getGroupNames(item.children)
}
})
}
getGroupNames([treeData])
postData = {
groupFieldName: this.groupFieldName,
groupname: this.treeNode.attributes.objectcode,
groupNames: objectCodes,
tableName: this.tableName,
pagination: true,
offset: (this.pageNo - 1) * this.pageSize,
limit: this.pageSize,
searchKey: this.searchInfo,
stopflag: -1,
queryDataStructure: "ALL",
authType: this.authType,
versionDate: this.versionDate,
expression: this.filterFormular,
'BI-SYNTAX': null
}
} else {
postData = {
pagination: true,
limit: this.pageSize,
offset: (this.pageNo - 1) * this.pageSize,
tableName: this.tableName,
searchKey: this.searchInfo,
queryDataStructure: 'ALL',
queryChildrenType: 'ALL_CHILDREN_WITH_SELF',
lazyload: false,
code: treeNode.code === '-'? '': treeNode.code,
authType: this.authType,
versionDate: this.versionDate,
expression: this.filterFormular,
'BI-SYNTAX': null
}
}
this.getBaseData(postData)
.then((response) => {
if (!(response || response.data)) {
this.tableDatas = []
return
}
const { rows, rs, total } = response.data
this.pageTotal = total
let _tabledatas = rows
this.refreshRowsCheckStatus(this.selection, _tabledatas)
this.tableDatas = _tabledatas
this.$emit('init-list', _tabledatas)
this.loading = false
})
.catch((err) => {
this.loading = false
console.error('获取表格信息失败:' + JSON.stringify(XMLHttpRequest))
console.log('error', err)
})
}
},
/**
* 刷新表格每行的勾选状态
* @param {Array} selected 已经选中的数据集合
* @param {Array} rows 表格行数据集合
*/
refreshRowsCheckStatus(selected, rows) {
let that = this
rows.map((value) => {
value._checked = that.isSelected(selected, value)
})
},
/**
* 判断指定行是否已经被选中
* @param {Object} row table表格行数据
*/
isSelected(selected, row) {
let result = false
selected.map((value) => {
if (value[this.primaryKey] == row[this.primaryKey]) {
result = true
return
}
})
return result
},
onPageChange(pageNo) {
this.pageNo = pageNo
this.refresh(this.treeNode)
},
onSelect(selection) {
this.selection = selection
},
onSelectCancel(selection, row) {
this.selection = selection
},
onSelectAll(selection) {
this.selection = selection
},
onSelectAllCancel(selection) {
this.selection = selection
},
onSearchEnter(searchInfo) {
this.searchInfo = searchInfo
this.pageNo = 1
this.refresh(this.treeNode)
},
onCancelSelected(item) {
for (let i = this.selection.length - 1; i >= 0; i--) {
if (this.selection[i].name == item.name) {
this.selection._checked = false
this.selection.splice(i, 1)
break
}
}
},
allCancel() {
this.selection.map((item) => {
item._checked = false
})
this.selection = []
},
},
}
</script>
\ No newline at end of file
<style lang="less" scoped>
.table-view-div {
width: 100%;
height: 100%;
position: relative;
}
.dept-personnel-header-div {
height: 35px;
margin-top: 0 !important;
.header-title-span {
margin: 0 10px 0 10px;
float: left;
width: 60px;
}
.just-selected {
float: left;
margin-left: 10px;
}
.fuzzy-search {
float: right;
min-width: 250px;
height: 30px;
}
.search-icon {
cursor: pointer;
font-size: 20px;
opacity: 0.5;
height: 28px;
}
.search-icon:hover {
color: #409c9c !important;
}
}
.dept-personnel-table-div {
height: calc(~'100% - 80px');
width: 100%;
}
.dept-personnel-table-class {
height: 100%;
width: 100%;
}
.dept-personnel-pager {
position: absolute;
bottom: 1px;
padding: 0 10px 0 10px;
height: 53px;
display: flex;
align-items: center;
width: 100%;
background-color: #fff;
}
.dept-personnel-single-select .ivu-table-header .ivu-checkbox-wrapper {
display: none;
}
</style>
<template>
<div
class="table-view-div"
ref="_tableView"
>
<div class="dept-personnel-header-div">
<div class="fuzzy-search">
<Input
v-model="searchInfo"
search
:placeholder="searchPlaceholder"
@on-search="onSearchEnter"
@on-clear="onSearchClear"
/>
</div>
</div>
<div
ref="_tableDiv"
class="dept-personnel-table-div"
>
<Table
ref="_table"
:class="tableClass"
:columns="columns"
:data="tableData"
:height="tableHeight"
border
stripe
:loading="loading"
@on-select="onSelect"
@on-select-cancel="onSelectCancel"
@on-select-all="onSelectAll"
@on-select-all-cancel="onSelectAllCancel"
>
</Table>
</div>
<div class="dept-personnel-pager">
<new-page
size="small"
:total="pageTotal"
:page-size="pageSize"
@on-change="onPageChange"
show-total
show-elevator
></new-page>
</div>
</div>
</template>
<script>
import NewPage from './new-page'
export default {
components: {
NewPage,
},
data() {
return {
tableData: [],
searchInfo: '',
tableHeight: 431,
}
},
props: {
treeDataMap: {
type: Object
},
structtype: {
type: Number
},
isLeaf: {
type: Boolean,
default: false
},
primaryKey: {
type: String,
require: true,
},
columns: {
type: Array,
require: true,
},
data: {
type: Array,
require: true,
},
pageTotal: {
type: Number,
default: () => 0,
},
pageSize: {
type: Number,
default: () => 20,
},
selection: {
type: Array,
default: () => [],
},
multiple: {
type: Boolean,
default: () => false,
},
loading: {
type: Boolean,
default: () => false,
},
searchPlaceholder: {
type: String,
default: '',
},
canSwitchMode: {
type: Boolean,
default: function () {
return true
},
},
},
watch: {
data: {
handler: function (newVal) {
this.tableData = JSON.parse(JSON.stringify(newVal))
if (this.isLeaf && this.structtype !== 1) {
// 后端不给返回是否是叶子节点的判断
this.tableData = this.tableData.map(item => {
if (this.treeDataMap[item.code] && this.treeDataMap[item.code].length === 0) {
item._disabled = false
} else {
item._disabled = true
}
return item
})
}
},
},
selection: {
handler: function (newVal) {
this.refreshTableSelected(newVal)
},
},
},
computed: {
tableClass: {
get: function () {
let _class = ['dept-personnel-table-class']
if (!this.multiple) {
_class.push('dept-personnel-single-select')
}
return _class.join(' ')
},
},
},
mounted() {
if (this.data) {
this.tableData = JSON.parse(JSON.stringify(this.data))
} else {
this.tableData = []
}
this.$nextTick(() => this.resizeTableHeight())
},
methods: {
resizeTableHeight() {
this.tableHeight = this.$refs['_tableView']
? this.$refs['_tableView'].offsetHeight - 84
: 431
},
resize() {},
onPageChange(pageNo) {
this.$emit('on-page-change', pageNo)
},
onSelect(selection, row) {
let _selection = []
if (this.multiple) {
_selection = JSON.parse(JSON.stringify(this.selection))
if (!this.isSelected(row)) {
_selection.push(JSON.parse(JSON.stringify(row)))
}
} else {
_selection.push(JSON.parse(JSON.stringify(row)))
}
this.updateCheckedStatus(_selection, true)
this.$emit('on-select', _selection, row)
},
isSelected(row, selection) {
let value = selection ? selection : this.selection
let obj = {}
obj[this.primaryKey] = row[this.primaryKey]
let selected = _.find(value, obj)
return selected ? true : false
},
onSelectCancel(selection, row) {
if (this.multiple) {
let _selection = JSON.parse(JSON.stringify(this.selection))
for (let i = _selection.length - 1; i >= 0; i--) {
if (row[this.primaryKey] == _selection[i][this.primaryKey]) {
_selection.splice(i, 1)
}
}
this.updateCheckedStatus(_selection, true)
this.$emit('on-select-cancel', _selection, row)
} else {
this.tableData.map((value) => (value._checked = false))
this.$emit('on-select-cancel', [], row)
}
},
onSelectAll(selection) {
this.multiple
? this.multipleSelectAll(selection)
: this.radioSelectAll(selection)
},
multipleSelectAll(selection) {
let _selection = JSON.parse(JSON.stringify(this.selection))
selection.map((value) => {
if (!this.isSelected(value)) {
_selection.push(value)
}
})
this.updateCheckedStatus(_selection, true)
this.$emit('on-select-all', _selection, selection)
},
radioSelectAll(selection) {
this.radioSelectAllCancel(selection)
},
onSelectAllCancel(selection) {
this.multiple
? this.multipleSelectAllCancel(selection)
: this.radioSelectAllCancel(selection)
},
radioSelectAllCancel(selection) {
this.tableData.map((row) => {
row._checked = false
this.selection.map((value) => {
if (value[this.primaryKey] == row[this.primaryKey]) {
row._checked = true
return
}
})
})
},
multipleSelectAllCancel(selection) {
let _selection = JSON.parse(JSON.stringify(this.selection))
let predicate = {}
for (let i = _selection.length - 1; i >= 0; i--) {
predicate[this.primaryKey] = _selection[i][this.primaryKey]
let obj = _.find(this.tableData, predicate)
if (obj) {
_selection.splice(i, 1)
}
}
this.updateCheckedStatus(_selection, true)
this.$emit('on-select-all-cancel', _selection)
},
updateCheckedStatus(array, status) {
array.map((value) => (value._checked = status))
},
onSearchEnter(val) {
this.searchInfo = val
this.$emit('on-search-enter', this.searchInfo)
},
onSearchClear(val) {
this.searchInfo = ''
this.$emit('on-search-enter', this.searchInfo)
},
refreshTableSelected(selection) {
this.tableData.map((item) => {
item._checked = this.isSelected(item, selection)
})
},
},
}
</script>
\ No newline at end of file
<style lang="less" scoped>
.tag-input-single {
min-height: 32px;
width: 100%;
position: relative;
.ivu-input-default {
padding-right: 25px;
}
}
.tag-input-multiple {
min-height: 32px;
width: 100%;
background: white;
border: 1px solid rgb(215, 221, 228);
border-radius: 6px;
position: relative;
}
.tag-input-multiple-disabled {
background-color: #f3f3f3;
opacity: 1;
cursor: not-allowed;
color: #ccc;
}
.tag-input-multiple-disabled:hover {
border: 1px solid rgb(215, 221, 228);
}
.tag-input-shade {
border-bottom-left-radius: 6px;
border-top-left-radius: 6px;
height: 100%;
position: absolute;
background: #ccc;
opacity: 0.2;
z-index: 1;
cursor: not-allowed;
}
.tag-input-container {
float: left;
overflow: hidden;
padding-left: 5px;
cursor: text;
}
.tag-input-arrow {
position: absolute;
top: 50%;
right: 8px;
line-height: 1;
transform: translateY(-50%);
font-size: 14px;
color: #808695;
transition: all 0.2s ease-in-out;
}
.tag-input-button-container {
overflow: hidden;
background-color: #eee;
height: 100%;
width: 35px;
border-left: 1px solid rgb(215, 221, 228);
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
position: absolute;
right: 0px;
padding-left: 10px;
button {
border-color: rgba(0, 0, 0, 0);
background-color: #eee;
font-size: 13px;
}
}
</style>
<template>
<div>
<div
v-if="!multiple"
class="tag-input-single"
:id="singleInputId"
@click="openModal"
@mouseenter="hasMouseHover = true"
@mouseleave="hasMouseHover = false"
>
<Input
:value="selection ? getInputLable(inputLabel, selection) : ''"
style="width:100%; height:100%;"
readonly
:disabled="disabled"
:placeholder="placeholder"
/>
<i
class="ivu-icon ivu-icon-ios-close-circle tag-input-arrow"
v-if="resetSelect"
@click.stop="onClear"
/>
<i
class="ivu-icon ivu-icon-ios-more tag-input-arrow"
style="font-size: 15px;"
v-if="!resetSelect"
@click="openModal"
/>
</div>
<div
v-else
:class="multipleClass"
:disabled="disabled"
@click="openModal"
@blur="handleBlur"
>
<div
class="tag-input-container"
style="width: calc(100% - 25px);"
>
<div style="width: 100%">
<Tag
v-for="(item,index) in showSelections"
:key="index"
:name="item.id"
closable
:fade="false"
@on-close="onTagClose"
style="margin-bottom:5px; position: relative; float: left;"
>{{getInputLable(inputLabel, item)}}</Tag>
<Tag
v-if="maxTagCount !== undefined && selection.length > maxTagCount"
style="margin-bottom:5px; position: relative; float: left;"
>+ {{ selection.length - maxTagCount }}...</Tag>
</div>
</div>
<i
class="ivu-icon ivu-icon-ios-more tag-input-arrow"
style="font-size: 15px;"
@click="openModal"
/>
<div style="clear:both"></div>
</div>
</div>
</template>
<script>
import Emitter from 'view-design/src/mixins/emitter'
import Locale from 'view-design/src/mixins/locale'
export default {
mixins: [Emitter, Locale],
props: {
disabled: {
type: Boolean,
default: false,
},
multiple: {
type: Boolean,
default: false,
},
selection: {
type: [Array, Object],
default: () => [],
},
clearable: {
type: Boolean,
default: false,
},
maxTagCount: {
type: Number,
},
placeholder: {
type: String,
},
inputLabel: {
type: String,
default: 'name',
validator: (value) => {
return value === 'code' || value === 'name' || value === 'codeName'
}
}
},
data() {
return {
singleInputId: 'tag-input-single',
// singleInputId: "tag-input-single" + SEDU.Util.newId(),
hasMouseHover: false, // 是否可以显示close图标
}
},
computed: {
multipleClass: {
get: function () {
let _class = ['tag-input-multiple']
if (this.disabled) {
_class.push('tag-input-multiple-disabled')
}
return _class.join(' ')
},
},
resetSelect: {
get: function () {
if (this.multiple) {
return false
}
return this.selection && this.clearable && this.hasMouseHover && !this.disabled
},
},
showSelections: {
get: function () {
let size = this.selection.length
if (this.maxTagCount === undefined || size <= this.maxTagCount) {
return this.selection
}
let result = []
for (let i = 0; i < this.maxTagCount; i++) {
result.push(this.selection[i])
}
return result
},
},
},
mounted() {
this.$nextTick(() => this.listernSingleDiv())
},
methods: {
listernSingleDiv() {
let elm = document.getElementById(this.singleInputId)
if (!elm) {
return
}
elm.onmouseover = () => (this.hasMouseHover = true)
elm.onmouseout = () => (this.hasMouseHover = false)
},
openModal() {
if (this.disabled) return
this.$emit('on-button-click')
},
onTagClose(event, name) {
if (this.disabled) return
this.$emit('on-tag-close', event, name)
},
handleBlur() {
this.$emit('on-blur', event)
this.dispatch && this.dispatch('FormItem', 'on-form-change', value)
},
onClear() {
this.$emit('on-clear', event, name)
},
getInputLable(prop, value) {
let result = ''
if(prop === 'codeName') {
result = value.code + ' ' + value.name
} else {
result = value[prop]
}
return result
}
},
watch: {},
}
</script>
\ No newline at end of file
<style lang="less" scoped>
.div_dept {
overflow: auto;
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 4px;
font-size: 13px;
}
</style>
<template>
<div class="div_dept">
<Tree
ref="_tree"
:data="treeData"
:load-data="loadData"
@on-select-change="onSelected"
/>
</div>
</template>
<script>
import baseDataMixin from './baseDataMixin'
export default {
mixins: [baseDataMixin],
data() {
return {
innerValue: [],
treeData: [],
allOrgTreeNode: [],
allDeptNode: [],
currSelectItem: null, // 记录当前选中项node信息
currLoadNode: {}, // 当前加载的节点,
treeDataMap: {} //由于基础数据过滤需求,使用list接口懒加载时接口无法返回被过滤节点的父节点且后端不改,只能首次加载整棵树但节点分多次渲染,且可以接受全部加载带来的性能问题
}
},
props: {
primaryKey: {
type: String,
require: true,
},
selectedId: {
type: Array,
default: () => [],
},
/**
* 指定根节点id,可为空
*/
rootId: {
type: String,
},
/**
* 指定根节点的数据类型, 可为空
*/
rootType: {
type: String,
},
filterList: {
type: Array,
default: () => []
}
},
computed: {
// 是否需要前端过滤树节点
isFilterTree() {
return this.structtype !== 1 && this.structtype !== -1 && this.isFilter
}
},
watch: {
selectedId: {
handler: function (newVal) {
this.initInnerValue(newVal)
},
deep: true,
},
filterList: {
handler: function(nv) {
this.getBaseDataList()
},
deep: true
}
},
mounted() {
this.getBaseDataList()
},
methods: {
async getBaseDataList() {
if (this.isOrg) {
let param = {
pagination: false,
parentcode: '-',
queryDataStructure: 'ALL',
}
let result = await this.getOrg(param)
this.treeData = this.formateTree(result)
} else {
// 修改list接口为tree接口
const getTreeDataMap = (nodes) => {
nodes.forEach(node => {
this.treeDataMap[node.id] = node.children? node.children: []
if (node.children) {
getTreeDataMap(node.children)
}
})
}
const postData = {
tableName: this.tableName,
queryDataStructure: 'ALL',
authType: this.authType,
versionDate: this.versionDate,
expression: this.filterFormular,
'BI-SYNTAX': null
}
if (this.structtype === 1) {
if (this.groupTableName.define.showFields) {
const relevance = this.groupTableName.define.showFields.find(item => item.columnName === this.groupTableName.groupFieldName)
let relevanceField = ''
if (relevance) {
relevanceField = relevance.mapping? relevance.mapping.split('.')[0]: ''
postData.tableName = relevanceField
}
}
}
const { data } = await this.getBaseData(postData, '/baseData/data/tree')
getTreeDataMap(data.rows)
this.$emit('init-tree', this.treeDataMap, this.groupTableName.groupFieldName)
// 默认展开根节点
const sonCodes = this.filterList.map(item => item.parents.split('/')[0])
const formateRootNode = (nodes) => {
let node = nodes[0]
node.expand = true
node.title = node.name || node.text
node.loading = false
node.code = node.code || node.id
if (node.children) {
let nodeChildren = []
if (this.isFilterTree) {
nodeChildren = node.children.filter(item => sonCodes.indexOf(item.id) !== -1)
} else {
nodeChildren = node.children
}
node.children = nodeChildren.map(item => {
if (item.hasChildren) {
item.children = []
item.loading = false
}
item.title = item.name || item.text
item.code = item.code || item.id
return item
})
}
return [node]
}
this.treeData = formateRootNode(data.rows)
}
let data = this.treeData
this.emitSelectEvent('on-select', data.length > 0? data[0]: {})
},
formateTree(data) {
return data.map((item) => {
item.children = []
item.title = item.name || item.text
item.loading = false
item.code = item.code || item.id
return item
})
},
initInnerValue(val) {
// 这里是按多选逻辑处理的,但目前这里只会有单选,不会有多选
let id = ''
if (val) {
this.innerValue = Array.isArray(val) ? val : [val]
id = val
} else {
this.innerValue = []
}
if (!this.currSelectItem || this.currSelectItem[this.primaryKey] != id) {
this.setInitSelectedSelectionState(id)
}
if (0 == this.innerValue.length) {
this.currSelectItem = null
}
},
setInitSelectedSelectionState(id) {
let tree = this.$refs['_tree'] ? this.$refs['_tree'].stateTree : undefined
if (!tree || tree.length == 0) {
return
}
tree.map((node) => {
let equal = this.isEqual(node, id)
node.selected = equal
if (equal) {
this.updateNodeSelectionState(node)
}
if (node.children && node.children.length > 0) {
this.updateTreeSelectionState(node.children, id)
}
})
},
isEqual(node, id) {
return node[this.primaryKey] == id
},
setDefaultSelectStatus() {
let node =
this.treeData && this.treeData.length > 0 ? this.treeData[0] : null
if (node && this.selectedId.length == 0) {
this.updateNodeSelectionState(node)
this.emitSelectEvent('on-select', node)
}
},
async loadData(item, callback) {
this.currLoadNode = item
if (this.isOrg) {
let param = {
pagination: false,
parentcode: this.currLoadNode.code,
queryDataStructure: 'ALL',
}
let result = await this.getOrg(param)
let arr = this.formateTree(result)
callback(arr)
} else {
// list接口更改为tree
let resultNodes = []
let nodes = this.formateTree(this.treeDataMap[item.id])
if (this.isFilterTree) {
nodes = nodes.filter(one => typeof this.filterList.find(x => x.code === one.id) === 'object')
}
resultNodes = nodes.map(one => {
if (one.hasChildren === false) {
delete one.loading
}
return one
})
callback(resultNodes)
}
},
/**
* 更新当前选中节点的下级节点
*/
updateCurrSelectionSubNodes(nodes) {
if (this.selectedId.length > 0) {
nodes.map((value) => {
let find = false
this.selectedId.map((id) => {
find = id == value[this.primaryKey]
})
if (find) {
this.updateNodeSelectionState(value)
return
}
})
}
},
onSelected(node, data) {
if (
!this.currSelectItem ||
this.currSelectItem[this.primaryKey] != data[this.primaryKey]
) {
this.updateNodeSelectionState(data)
this.emitSelectEvent('on-select', data)
}
},
emitSelectEvent(eventName, node) {
this.$emit(eventName, node[this.primaryKey], node)
},
updateNodeSelectionState(item) {
if (this.currSelectItem) {
this.$set(this.currSelectItem, 'selected', false)
}
this.currSelectItem = item
if (item) {
this.$set(this.currSelectItem, 'selected', true)
}
},
},
}
</script>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment