import bUpload from '../../../base/behaviors/bUpload';
|
import selfpatrolservice from '../../../service/selfpatrolservice';
|
import bLoadingStatus from '../../../base/behaviors/bLoadingStatus';
|
import moment from '../../../utils/moment.min';
|
|
const app = getApp();
|
|
/**
|
* 应急自巡查上传管理
|
*/
|
module.exports = Behavior({
|
behaviors: [bUpload, bLoadingStatus],
|
data: {
|
ledger: {},
|
remark: '',
|
},
|
methods: {
|
_uploadSelfPatrol() {
|
if (this.data.imgFiles.length == 0) return;
|
|
var that = this;
|
// 文件路径
|
let path = [];
|
this.data.imgFiles.forEach(f => {
|
path.push(f.url);
|
});
|
// 应急自巡查台账信息
|
const { ledger, taskId } = this.data;
|
ledger.remark1 = this.data.remark;
|
if (this.data.detail) {
|
ledger.id = this.data.detail.id
|
}
|
// 文件临时名称和原始名称配对信息
|
let namePairs = []
|
this.data.imgFiles.forEach(f=>{
|
// 除了图片外的文档需要传输原始名字
|
if (f.name) {
|
const ulist = f.url.split('/')
|
namePairs.push({
|
first: ulist[ulist.length - 1], // 上传的临时文件名字
|
second: f.name // 文件原始名字
|
})
|
}
|
})
|
|
this.setData({ loading: true });
|
selfpatrolservice.uploadSelfPatrol(
|
app.globalData.accessToken.userId,
|
taskId,
|
ledger,
|
namePairs,
|
path,
|
{
|
success(res) {
|
that.setData({ loading: false });
|
if (typeof that._success === 'function') {
|
that._success(res);
|
}
|
},
|
fail(err) {
|
that.setData({ loading: false });
|
},
|
complete(res) {},
|
},
|
);
|
},
|
|
_uploadNoSelfPatrol() {
|
var that = this;
|
const { taskId } = this.data;
|
const time = moment().format('YYYY-MM-DD');
|
const idList = [this.data.ledger.ledgerSubTypeId];
|
this.setData({ loading: true });
|
selfpatrolservice.uploadNoSelfPatrol(
|
app.globalData.accessToken.userId,
|
taskId,
|
time,
|
this.data.remark,
|
idList,
|
{
|
success(res) {
|
that.setData({ loading: false });
|
if (typeof that._success === 'function') {
|
that._success(res);
|
}
|
},
|
fail(err) {
|
that.setData({ loading: false });
|
},
|
},
|
);
|
},
|
},
|
});
|