123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- var app = getApp();
- var that;
- import moment from 'moment' // 时间库
- Page({
- data: {
- tabIndex: 1,//条件选择
- list: [],
- page: 1,
- id: '',
- packageName: '',
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "结果值录入" });
- this.setData({
- id: e.id,
- packageName: e.tel,
- })
- this.getPackageDtail()
- },
- tabAction(e) {
- let index = e.target.dataset.index
- this.setData({
- tabIndex: index,
- })
- this.getPackageDtail()
- },
- bindTextAreaBlur(e) {
- this.setData({
- [`rvenotList[${e.target.dataset.index}].result`]: e.detail.value,
- });
- },
- deleteImg(e) {
- let item = e.target.dataset.item
- let index = e.target.dataset.index
- let indexT = e.target.dataset.indexT
- if (item.length == 1) {
- this.setData({
- [`rvenotList[${index}].result_file.append`]: [],
- })
- return false
- }
- item.splice(indexT, 1)
-
- this.setData({
- [`rvenotList[${index}].result_file.append`]: item,
- })
- console.log(item,index,indexT,this.data.rvenotList[index])
- },
- showImg(e) {
- let item = e.target.dataset.item
- app.$get('api/drive/grant', { file_id: item.fileId }).then(res => {
- dd.previewFileInDingTalk({
- corpId: app.globalData.corpId,
- spaceId: item.spaceId,
- fileId: item.fileId,
- fileName: item.fileName,
- fileSize: item.fileSize,
- fileType: item.fileType,
- })
- })
- },
- //图片选择
- openImg(e) {
- let index = e.target.dataset.index
- let append = this.data.rvenotList[index].result_file.append;
- app.$get('api/drive/info').then(res => {
- let spaceId = res.data.data.space_id.toString()
- dd.uploadAttachmentToDingTalk({
- image: { multiple: true, compress: false, max: 5, spaceId: spaceId },
- space: { spaceId: spaceId, isCopy: 1, max: 5 },
- file: { spaceId: spaceId, max: 5 },
- types: ["photo", "file", "space"],//PC端仅支持["photo","file","space"]
- success: (res) => {
- console.log(res);
- append.push(...res.data);
- that.setData({
- [`rvenotList[${e.target.dataset.index}].result_file.append`]: append,
- });
- },
- fail: (err) => {
- console.log(err)
- }
- })
- })
- },
- // 提交
- save(e) {
- let num = e.target.dataset.index
- let isLr = false;
- let data = {
- id: this.data.id, // 个人考核包ID
- cache: num, // 是否暂存 1 是 0 否(提交)
- result_info: '' // 结果值信息
- };
- let result_info = [];
- this.data.rvenotList.some(item => {
- if(item.type==1){
- if (item.result) {
- result_info.push({
- result: item.result, // 单项目结果值
- dimension_key: item.message.dimension_key, // 维度索引
- index_key: item.message.index_key, // 指标索引
- index_id: item.id, // 指标ID
- result_file: item.result_file
- });
- isLr = true;
- }
- }else{
- // if (item.result_file.append.length > 0) {
- result_info.push({
- result: item.result, // 单项目结果值
- dimension_key: item.message.dimension_key, // 维度索引
- index_key: item.message.index_key, // 指标索引
- index_id: item.id, // 指标ID
- result_file: item.result_file
- });
- isLr = true;
- // }
- }
- });
- if (!isLr) {
- app.globalData.showToast('至少输入一项结果值');
- return false;
- }
- data.result_info = JSON.stringify(result_info);
- if (this.data.bootBool) {
- return;
- }
- this.setData({
- bootBool: true
- })
- app.$post('api/per/package/record_result', data)
- .then(res => {
- this.getPackageDtail();
- setTimeout(() => {
- app.globalData.showToast(num == '1' ? '暂存成功' : '提交成功');
- this.setData({
- bootBool: false
- })
- }, 1000);
- })
- },
- getPackageDtail() {
- app.$get2('api/per/package/employee/info', { id: this.data.id }).then(res => {
- let data = res.data.data;
- let dimension = data.dimension;
- let relevance_employee = data.relevance_employee;
- dimension.forEach((item, index) => {
- if (item.index.length > 0) {
- item.index.forEach((item2, index2) => {
- item2.wdName = item.name;
- item2.userName = relevance_employee.name;
- item2.userId = relevance_employee.id;
- item2.dept_list = relevance_employee.dept_list;
- item2.dil = [
- {
- lab: '考核标准',
- prop: item2.per_remark ? item2.per_remark : null
- },
- { lab: '目标值', prop: item2.target ? item2.target : null },
- { lab: '权重%', prop: item2.weight ? item2.weight : null },
- { lab: '备注', prop: item2.remark ? item2.remark : null }
- ];
- });
- }
- });
- let flow = data.flow;
- let list = []; // 结果值录入集合
- flow.forEach(item => {
- if (item.code == 'result_value') {
- item.target.forEach(item2 => {
- if (item2.employee_id == app.globalData.userData.id) {
- list = item2.list;
- // status = item2.status;
- }
- });
- }
- });
- let statusList = []; // 已录入指标
- let noStatusList = []; // 未录入指标
- list.forEach(item => {
- if (item.status == 2) {
- dimension[item.dimension_key].index[item.index_key].message = item;
- statusList.push(dimension[item.dimension_key].index[item.index_key]);
- }
- if (item.status == 1) {
- dimension[item.dimension_key].index[item.index_key].message = item;
- if (item.result_cache) {
- // 是否有暂存的数据有就显示出来
- dimension[item.dimension_key].index[item.index_key].result = item.result_cache;
- dimension[item.dimension_key].index[item.index_key].result_file = item.result_file;
- }
- noStatusList.push(dimension[item.dimension_key].index[item.index_key]);
- }
- });
- this.setData({
- statusList: statusList,
- noStatusList: noStatusList,
- })
- if (this.data.tabIndex == 1) {
- this.setData({
- rvenotList: this.data.noStatusList
- })
- } else if (this.data.tabIndex == 2) {
- this.setData({
- rvenotList: this.data.statusList
- })
- }
- this.setData({
- age: { num1: noStatusList.length, num2: statusList.length }
- })
- })
- }
- });
|