12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- module.exports = app => {
- class Valuation extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'valuation_list';
- }
- async getProjectValidValuation(pid) {
- const project = await this.ctx.service.project.getDataById(pid);
- const vid = this._.map(project.valuation.split(','), this._.toInteger);
- return await this.db.select(this.tableName, {
- where: {id: vid},
- columns: ['id', 'name'],
- });
- }
- async getValuationTemplate(id) {
- const valuation = await this.getDataById(id);
- return parseInt(valuation.template_id);
- }
- async getValuationStdList(id) {
- const valuation = await this.getDataById(id);
- const billsId = this._.map(valuation.bill_id.split(','), this._.toInteger);
- const chaptersId = this._.map(valuation.chapter_id.split(','), this._.toInteger);
- const billsList = await this.db.select('zh_std_gcl_list', {
- where: {id: billsId},
- columns: ['id', 'name'],
- });
- billsList.sort(function (a, b) {
- return billsId.indexOf(a.id) - billsList.indexOf(b.id);
- });
- const chapterList = await this.db.select('zh_std_xmj_list', {
- where: {id: chaptersId},
- columns: ['id', 'name'],
- });
- chapterList.sort(function (a, b) {
- return chaptersId.indexOf(a.id) - chapterList.indexOf(b.id);
- });
- return [billsList, chapterList];
- }
- }
- return Valuation;
- };
|