明树Git Lab

Commit 5e8699d7 authored by zfp1's avatar zfp1

update

parent da1ba7a1
Pipeline #109064 passed with stage
in 3 seconds
...@@ -94,11 +94,95 @@ async function deleteCbgl(req, res, next) { ...@@ -94,11 +94,95 @@ async function deleteCbgl(req, res, next) {
} }
} }
// 创建工抵房
async function createGdf(req, res, next) {
try {
let ret = await DB.QtGdf.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
// 更新工抵房
async function updateGdf(req, res, next) {
try {
if (!req.body.id) return res.sendError(errorMessage.paramsError);
let ret = await DB.QtGdf.findOne({ where: { id: req.body.id }, raw: true });
if (!(ret && ret.id)) return res.sendError(errorMessage.resourceNotFound);
await DB.QtGdf.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
// 获取单个工抵房
async function getGdf(req, res, next) {
try {
if (!req.body.id) return res.sendError(errorMessage.paramsError);
let info = await DB.QtGdf.findOne({ where: { id: req.body.id, del: 0 }, raw: true });
if (!(info && info.id)) return res.sendError(errorMessage.resourceNotFound);
return res.sendData(info);
} catch (error) {
next(error);
}
}
// 获取工抵房列表
async function getGdfList(req, res, next) {
try {
let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10;
let offset = (page - 1) * limit;
let search = {};
search.order = [['id', 'DESC']];
search.limit = limit;
search.offset = offset;
let where = { del: 0 };
if (req.body.projectName) {
where.projectName = { [Op.like]: `%${req.body.projectName}%` };
}
if (req.body.registrationNo) {
where.registrationNo = { [Op.like]: `%${req.body.registrationNo}%` };
}
if (req.body.contractNo) {
where.contractNo = { [Op.like]: `%${req.body.contractNo}%` };
}
if (req.body.projectId) {
where.projectId = req.body.projectId;
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.QtGdf.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
// 删除工抵房(逻辑删除)
async function deleteGdf(req, res, next) {
try {
await DB.QtGdf.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
module.exports = { module.exports = {
createCbgl, createCbgl,
updateCbgl, updateCbgl,
getCbgl, getCbgl,
getCbglList, getCbglList,
deleteCbgl deleteCbgl,
createGdf,
updateGdf,
getGdf,
getGdfList,
deleteGdf
}; };
...@@ -92,6 +92,7 @@ const RcXxhjs = require('./model/jt/rcXxhjs'); ...@@ -92,6 +92,7 @@ const RcXxhjs = require('./model/jt/rcXxhjs');
const RcTzdagl = require('./model/jt/rcTzdagl'); const RcTzdagl = require('./model/jt/rcTzdagl');
const QtCbgl = require('./model/jt/qtCbgl'); const QtCbgl = require('./model/jt/qtCbgl');
const QtGdf = require('./model/jt/qtGdf');
/** /**
* 业务表 * 业务表
*/ */
...@@ -180,6 +181,7 @@ global.DB = { ...@@ -180,6 +181,7 @@ global.DB = {
RcXxhjs, RcXxhjs,
RcTzdagl, RcTzdagl,
QtCbgl, QtCbgl,
QtGdf,
} }
...@@ -304,4 +306,4 @@ ProjectXmtzze.belongsTo(Project, { foreignKey: 'projectId' }); ...@@ -304,4 +306,4 @@ ProjectXmtzze.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-项目流转记录 */ /**项目-项目流转记录 */
// Project.hasMany(FlowRecord, { foreignKey: 'projectId', as: 'flowRecords' }); // Project.hasMany(FlowRecord, { foreignKey: 'projectId', as: 'flowRecords' });
// FlowRecord.belongsTo(Project, { foreignKey: 'projectId' }); // FlowRecord.belongsTo(Project, { foreignKey: 'projectId' });
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
// 其他 - 工抵房
const QtGdf = sequelize.define('QtGdf', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
registrationNo: {
type: DataTypes.STRING,
comment: "登记编号"
},
registrationDate: {
type: DataTypes.DATE,
comment: "登记日期",
get() {
const rawValue = this.getDataValue('registrationDate');
return rawValue ? moment(rawValue).format('YYYY-MM-DD') : '';
}
},
projectName: {
type: DataTypes.STRING,
comment: "项目名称"
},
deductionType: {
type: DataTypes.STRING,
comment: "抵扣类型(工程款/材料款/其他)"
},
contractAmount: {
type: DataTypes.DECIMAL(19, 2),
comment: "合同金额"
},
deductionRate: {
type: DataTypes.DECIMAL(5, 2),
comment: "抵扣比例"
},
deductionAmount: {
type: DataTypes.DECIMAL(19, 2),
comment: "抵扣金额"
},
contractNo: {
type: DataTypes.STRING,
comment: "合同编号"
},
contractScanFiles: {
type: DataTypes.JSON,
defaultValue: [],
comment: "合同扫描件"
},
offsetSigningDate: {
type: DataTypes.DATE,
comment: "工抵签订时间",
get() {
const rawValue = this.getDataValue('offsetSigningDate');
return rawValue ? moment(rawValue).format('YYYY-MM-DD') : '';
}
},
handlerName: {
type: DataTypes.STRING,
comment: "经办人"
},
partyAName: {
type: DataTypes.STRING,
comment: "甲方名称"
},
partyAContact: {
type: DataTypes.STRING,
comment: "甲方联系人"
},
partyAPhone: {
type: DataTypes.STRING,
comment: "甲方联系方式"
},
partyBName: {
type: DataTypes.STRING,
comment: "乙方名称"
},
partyBContact: {
type: DataTypes.STRING,
comment: "乙方联系人"
},
partyBPhone: {
type: DataTypes.STRING,
comment: "乙方联系方式"
},
partyCName: {
type: DataTypes.STRING,
comment: "丙方名称"
},
partyCContact: {
type: DataTypes.STRING,
comment: "丙方联系人"
},
partyCPhone: {
type: DataTypes.STRING,
comment: "丙方联系方式"
},
projectAddress: {
type: DataTypes.STRING,
comment: "项目地址"
},
projectCompany: {
type: DataTypes.STRING,
comment: "项目公司"
},
projectStatus: {
type: DataTypes.STRING,
comment: "项目状态(在建/已竣工)"
},
buildingInfo: {
type: DataTypes.STRING,
comment: "楼栋信息"
},
propertyType: {
type: DataTypes.STRING,
comment: "房源类型(住宅/公寓/商铺/车位)"
},
buildingArea: {
type: DataTypes.DECIMAL(19, 2),
comment: "建筑面积(㎡)"
},
unitPrice: {
type: DataTypes.DECIMAL(19, 2),
comment: "单价(元/㎡)"
},
totalAmount: {
type: DataTypes.DECIMAL(19, 2),
comment: "总金额(元)"
},
attachments: {
type: DataTypes.JSON,
defaultValue: [],
comment: "附件上传"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: Date.now,
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: {
type: DataTypes.DATE,
defaultValue: Date.now,
get() {
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_qt_gdf',
timestamps: true,
});
QtGdf.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('QtGdf 表同步成功');
});
module.exports = QtGdf;
...@@ -218,4 +218,11 @@ router.post('/getCbgl', projectQtController.getCbgl); ...@@ -218,4 +218,11 @@ router.post('/getCbgl', projectQtController.getCbgl);
router.post('/getCbglList', projectQtController.getCbglList); router.post('/getCbglList', projectQtController.getCbglList);
router.post('/deleteCbgl', projectQtController.deleteCbgl); router.post('/deleteCbgl', projectQtController.deleteCbgl);
module.exports = router; //5.2 工抵房
\ No newline at end of file router.post('/createGdf', projectQtController.createGdf);
router.post('/updateGdf', projectQtController.updateGdf);
router.post('/getGdf', projectQtController.getGdf);
router.post('/getGdfList', projectQtController.getGdfList);
router.post('/deleteGdf', projectQtController.deleteGdf);
module.exports = router;
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