|
@@ -80,14 +80,14 @@ const Cost = (function(){
|
|
|
{ key: 'code', name: '编号', fields: ['code'], valid: ['title', 'width'], def: { title: '编号', width: 80, type: 'code'} },
|
|
{ key: 'code', name: '编号', fields: ['code'], valid: ['title', 'width'], def: { title: '编号', width: 80, type: 'code'} },
|
|
|
{ key: 'name', name: '名称', fields: ['name'], valid: ['title', 'width'], def: { title: '名称', width: 80, type: 'name'} },
|
|
{ key: 'name', name: '名称', fields: ['name'], valid: ['title', 'width'], def: { title: '名称', width: 80, type: 'name'} },
|
|
|
{ key: 'party_b', name: '乙方', fields: ['party_b'], valid: ['title', 'width'], def: { title: '乙方', width: 80, type: 'party_b'} },
|
|
{ key: 'party_b', name: '乙方', fields: ['party_b'], valid: ['title', 'width'], def: { title: '乙方', width: 80, type: 'party_b'} },
|
|
|
- { key: 'yf_excl_tax_tp', name: '应付(不含税)', fields: ['yf_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal'], def: { title: '已结(不含税)', width: 80, type: 'yf_excl_tax_tp', decimal: 6} },
|
|
|
|
|
- { key: 'in_excl_tax_tp', name: '入账(不含税)', fields: ['in_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal'], def: { title: '入账(不含税)', width: 80, type: 'in_excl_tax_tp', decimal: 6} },
|
|
|
|
|
- { key: 'sf_excl_tax_tp', name: '实付(不含税)', fields: ['sf_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal'], def: { title: '实付(不含税)', width: 80, type: 'sf_excl_tax_tp', decimal: 6} },
|
|
|
|
|
|
|
+ { key: 'yf_excl_tax_tp', name: '应付(不含税)', fields: ['yf_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal', 'sum'], def: { title: '已结(不含税)', width: 80, type: 'yf_excl_tax_tp', decimal: 6} },
|
|
|
|
|
+ { key: 'in_excl_tax_tp', name: '入账(不含税)', fields: ['in_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal', 'sum'], def: { title: '入账(不含税)', width: 80, type: 'in_excl_tax_tp', decimal: 6} },
|
|
|
|
|
+ { key: 'sf_excl_tax_tp', name: '实付(不含税)', fields: ['sf_excl_tax_tp'], valid: ['title', 'width', 'calc_code', 'decimal', 'sum'], def: { title: '实付(不含税)', width: 80, type: 'sf_excl_tax_tp', decimal: 6} },
|
|
|
{ key: 'str', name: '文本', fields: ['str1', 'str2', 'str3', 'str4'], valid: ['title', 'width'], def: { title: '文本', width: 80, type: 'str'} },
|
|
{ key: 'str', name: '文本', fields: ['str1', 'str2', 'str3', 'str4'], valid: ['title', 'width'], def: { title: '文本', width: 80, type: 'str'} },
|
|
|
{
|
|
{
|
|
|
key: 'num', name: '数值/计算',
|
|
key: 'num', name: '数值/计算',
|
|
|
fields: ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i', 'num_j', 'num_k', 'num_l', 'num_m', 'num_n', 'num_o', 'num_p'], // 'num_q', 'num_r', 'num_s', 'num_t', 'num_u', 'num_v', 'num_w', 'num_x', 'num_y', 'num_z'],
|
|
fields: ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i', 'num_j', 'num_k', 'num_l', 'num_m', 'num_n', 'num_o', 'num_p'], // 'num_q', 'num_r', 'num_s', 'num_t', 'num_u', 'num_v', 'num_w', 'num_x', 'num_y', 'num_z'],
|
|
|
- valid: ['title', 'width', 'calc_code', 'decimal', 'unit', 'expr'],
|
|
|
|
|
|
|
+ valid: ['title', 'width', 'calc_code', 'decimal', 'unit', 'expr', 'sum'],
|
|
|
def: { title: '数值/计算', width: 80, decimal: 6, type: 'num', unit: ''}
|
|
def: { title: '数值/计算', width: 80, decimal: 6, type: 'num', unit: ''}
|
|
|
},
|
|
},
|
|
|
{ key: 'postil', name: '本期批注', fields: ['postil'], valid: ['title', 'width'], def: { title: '本期批注', width: 120, type: 'postil'} },
|
|
{ key: 'postil', name: '本期批注', fields: ['postil'], valid: ['title', 'width'], def: { title: '本期批注', width: 120, type: 'postil'} },
|
|
@@ -170,6 +170,23 @@ module.exports = app => {
|
|
|
await this.analysisTemplate(result);
|
|
await this.analysisTemplate(result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+ async getProjectCalcTmplSet () {
|
|
|
|
|
+ if (this.projectSet) return;
|
|
|
|
|
+ const defaultSet = { posCalc: { validCount: 50 }, cost: { validCount: 10 } };
|
|
|
|
|
+ const project = await this.ctx.service.project.getDataById(this.ctx.session.sessionProject.id);
|
|
|
|
|
+ if (!project.calc_tmpl_set) {
|
|
|
|
|
+ this.projectSet = defaultSet;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.projectSet = JSON.parse(project.calc_tmpl_set);
|
|
|
|
|
+ for (const prop in defaultSet) {
|
|
|
|
|
+ if (this.projectSet[prop]) {
|
|
|
|
|
+ this.projectSet[prop] = this.ctx.helper._.assign(defaultSet[prop], this.projectSet[prop]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.projectSet[prop] = defaultSet[prop];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//-------------------------- 以下方法不可随意修改 --------------------------
|
|
//-------------------------- 以下方法不可随意修改 --------------------------
|
|
|
// 根据列设置计算spreadjs配置相关,方法命名须严格按照【方法_类型】命名
|
|
// 根据列设置计算spreadjs配置相关,方法命名须严格按照【方法_类型】命名
|
|
@@ -360,8 +377,9 @@ module.exports = app => {
|
|
|
|
|
|
|
|
async _addTemplate(name, type, folder_id) {
|
|
async _addTemplate(name, type, folder_id) {
|
|
|
if (ValidTemplateType.indexOf(type) < 0) throw '新增的模板类型非法';
|
|
if (ValidTemplateType.indexOf(type) < 0) throw '新增的模板类型非法';
|
|
|
|
|
+ await this.getProjectCalcTmplSet();
|
|
|
const count = await this.count({pid: this.ctx.session.sessionProject.id, type});
|
|
const count = await this.count({pid: this.ctx.session.sessionProject.id, type});
|
|
|
- if (count > this.TemplateRela[type].ValidCount) throw '已达模板使用上限';
|
|
|
|
|
|
|
+ if (count >= this.projectSet[type].validCount) throw '已达模板使用上限';
|
|
|
|
|
|
|
|
const relaConst = this.TemplateRela[type];
|
|
const relaConst = this.TemplateRela[type];
|
|
|
const insertData = {
|
|
const insertData = {
|
|
@@ -497,12 +515,46 @@ module.exports = app => {
|
|
|
await this.db.updateRows(this.tableName, updateData);
|
|
await this.db.updateRows(this.tableName, updateData);
|
|
|
return updateData;
|
|
return updateData;
|
|
|
}
|
|
}
|
|
|
|
|
+ async _copyTemplate(id, folder_id) {
|
|
|
|
|
+ const org = await this.getDataById(id);
|
|
|
|
|
+ if (!org || org.pid !== this.ctx.session.sessionProject.id) throw '复制的模板不存在,请刷新后重试';
|
|
|
|
|
+
|
|
|
|
|
+ await this.getProjectCalcTmplSet();
|
|
|
|
|
+ const count = await this.count({pid: this.ctx.session.sessionProject.id, type});
|
|
|
|
|
+ if (count >= this.projectSet[org.type].validCount) throw '已达模板使用上限';
|
|
|
|
|
+
|
|
|
|
|
+ const insertData = {
|
|
|
|
|
+ id: this.uuid.v4(),
|
|
|
|
|
+ pid: this.ctx.session.sessionProject.id,
|
|
|
|
|
+ folder_id: folder_id,
|
|
|
|
|
+ name: org.name,
|
|
|
|
|
+ type: org.type,
|
|
|
|
|
+ create_user_id: this.ctx.session.sessionUser.accountId,
|
|
|
|
|
+ update_user_id: this.ctx.session.sessionUser.accountId,
|
|
|
|
|
+ col_set: org.col_set,
|
|
|
|
|
+ spread_cache: org.spread_cache,
|
|
|
|
|
+ sub_spread_cache: org.sub_spread_cache,
|
|
|
|
|
+ field_cache: org.field_cache,
|
|
|
|
|
+ decimal: org.decimal,
|
|
|
|
|
+ calc_expr: org.calc_expr,
|
|
|
|
|
+ calc_order: org.calc_order,
|
|
|
|
|
+ spec_set: org.spec_set,
|
|
|
|
|
+ spec_rela: org.spec_rela,
|
|
|
|
|
+ multi_header: org.multi_header,
|
|
|
|
|
+ };
|
|
|
|
|
+ await this.db.insert(this.tableName, insertData);
|
|
|
|
|
+
|
|
|
|
|
+ const result = await this.getTemplate(insertData.id);
|
|
|
|
|
+ result.user_name = this.ctx.session.sessionUser.name;
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
async saveTemplate(data) {
|
|
async saveTemplate(data) {
|
|
|
const result = {};
|
|
const result = {};
|
|
|
if (data.add) result.add = await this._addTemplate(data.add.name, data.type, data.add.folder_id);
|
|
if (data.add) result.add = await this._addTemplate(data.add.name, data.type, data.add.folder_id);
|
|
|
if (data.del) result.del = await this._delTemplate(data.del);
|
|
if (data.del) result.del = await this._delTemplate(data.del);
|
|
|
if (data.update) result.update = await this._saveTemplate(data.update.id, data.update);
|
|
if (data.update) result.update = await this._saveTemplate(data.update.id, data.update);
|
|
|
if (data.move) result.move = await this._moveTemplate(data.move, data.folder_id);
|
|
if (data.move) result.move = await this._moveTemplate(data.move, data.folder_id);
|
|
|
|
|
+ if (data.copy) result.copy = await this._copyTemplate(data.copy.id, data.copy.folder_id);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
async reCalcTemplate(id, force) {
|
|
async reCalcTemplate(id, force) {
|