|
|
@@ -174,8 +174,9 @@ Page({
|
|
|
hotel: '',//酒店
|
|
|
room: '',//房间
|
|
|
mInputId: '',//自动滚动用的
|
|
|
- intervalId1: null,
|
|
|
+ intervalId1: null,//保存数据
|
|
|
intervalId2: null,//授权解除定时任务
|
|
|
+ intervalId3: null,//导出excel
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -380,72 +381,72 @@ Page({
|
|
|
|
|
|
if (item == 'A') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",气虚型";
|
|
|
+ _comScoreStatus += "\n气虚型";
|
|
|
}else{
|
|
|
_comScoreStatus += "气虚型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",气虚型:填写内容";
|
|
|
+ _comScoreDesc += "\n气虚型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "气虚型:填写内容";
|
|
|
}
|
|
|
comScoreIndex.push(0);
|
|
|
} else if (item == 'B') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",气滞型";
|
|
|
+ _comScoreStatus += "\n气滞型";
|
|
|
}else{
|
|
|
_comScoreStatus += "气滞型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",气滞型:填写内容";
|
|
|
+ _comScoreDesc += "\n气滞型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "气滞型:填写内容";
|
|
|
}
|
|
|
comScoreIndex.push(1);
|
|
|
} else if (item == 'C') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",血虚型";
|
|
|
+ _comScoreStatus += "\n血虚型";
|
|
|
}else{
|
|
|
_comScoreStatus += "血虚型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",血虚型:填写内容";
|
|
|
+ _comScoreDesc += "\n血虚型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "血虚型:填写内容";
|
|
|
}
|
|
|
comScoreIndex.push(2);
|
|
|
} else if (item == 'D') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",淤血型";
|
|
|
+ _comScoreStatus += "\n淤血型";
|
|
|
}else{
|
|
|
_comScoreStatus += "淤血型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",淤血型:填写内容";
|
|
|
+ _comScoreDesc += "\n淤血型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "淤血型:填写内容";
|
|
|
}
|
|
|
comScoreIndex.push(3);
|
|
|
} else if (item == 'E') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",水虚型";
|
|
|
+ _comScoreStatus += "\n水虚型";
|
|
|
}else{
|
|
|
_comScoreStatus += "水虚型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",水虚型:填写内容";
|
|
|
+ _comScoreDesc += "\n水虚型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "水虚型:填写内容";
|
|
|
}
|
|
|
comScoreIndex.push(4);
|
|
|
} else if (item == 'F') {
|
|
|
if(_comScoreStatus){
|
|
|
- _comScoreStatus += ",痰湿型";
|
|
|
+ _comScoreStatus += "\n痰湿型";
|
|
|
}else{
|
|
|
_comScoreStatus += "痰湿型";
|
|
|
}
|
|
|
if(_comScoreDesc){
|
|
|
- _comScoreDesc += ",痰湿型:填写内容";
|
|
|
+ _comScoreDesc += "\n痰湿型:填写内容";
|
|
|
}else{
|
|
|
_comScoreDesc += "痰湿型:填写内容";
|
|
|
}
|
|
|
@@ -470,15 +471,15 @@ Page({
|
|
|
room: this.data.room,
|
|
|
userId: nickName,
|
|
|
id2: unionid,
|
|
|
- bodySynthesis: (!this.data.bodySynthesis || this.data.bodySynthesis.length === 0) ? '' : (Array.isArray(this.data.bodySynthesis) ? this.data.bodySynthesis.map(item => String(item)).join(',') : this.data.bodySynthesis),
|
|
|
- facialFeatures: (!this.data.facialFeatures || this.data.facialFeatures.length === 0) ? '' : (Array.isArray(this.data.facialFeatures) ? this.data.facialFeatures.map(item => String(item)).join(',') : this.data.facialFeatures),
|
|
|
- skinHair: (!this.data.skinHair || this.data.skinHair.length === 0) ? '' : (Array.isArray(this.data.skinHair) ? this.data.skinHair.map(item => String(item)).join(',') : this.data.skinHair),
|
|
|
- emotion: (!this.data.emotion || this.data.emotion.length === 0) ? '' : (Array.isArray(this.data.emotion) ? this.data.emotion.map(item => String(item)).join(',') : this.data.emotion),
|
|
|
- menstruation: (!this.data.menstruation || this.data.menstruation.length === 0) ? '' : (Array.isArray(this.data.menstruation) ? this.data.menstruation.map(item => String(item)).join(',') : this.data.menstruation),
|
|
|
- character: (!this.data.character || this.data.character.length === 0) ? '' : (Array.isArray(this.data.character) ? this.data.character.map(item => String(item)).join(',') : this.data.character),
|
|
|
- sleep: (!this.data.sleep || this.data.sleep.length === 0) ? '' : (Array.isArray(this.data.sleep) ? this.data.sleep.map(item => String(item)).join(',') : this.data.sleep),
|
|
|
+ bodySynthesis: this.getFormattedString(this.data.bodySynthesis,this.data.bodySynthesisOptions),
|
|
|
+ facialFeatures: this.getFormattedString(this.data.facialFeatures,this.data.facialFeaturesOptions),
|
|
|
+ skinHair: this.getFormattedString(this.data.skinHair,this.data.skinHairOptions),
|
|
|
+ emotion: this.getFormattedString(this.data.emotion,this.data.emotionOptions),
|
|
|
+ menstruation: this.getFormattedString(this.data.menstruation,this.data.menstruationOptions),
|
|
|
+ character: this.getFormattedString(this.data.character,this.data.characterOptions),
|
|
|
+ sleep: this.getFormattedString(this.data.sleep,this.data.sleepOptions),
|
|
|
//舌头状态是新增加项,赋给value1了,数据库里有value1...value8,以备增加项用
|
|
|
- value1: (!this.data.tongueState || this.data.tongueState.length === 0) ? '' : (Array.isArray(this.data.tongueState) ? this.data.tongueState.map(item => String(item)).join(',') : this.data.tongueState),
|
|
|
+ value1: this.getFormattedString(this.data.tongueState,this.data.tongueStateOptions),
|
|
|
//value2 保存A、B、C、D、E、F 每个的个数
|
|
|
value2:JSON.stringify(countABCDEF),
|
|
|
comScoreStatus: _comScoreStatus,
|
|
|
@@ -556,6 +557,61 @@ Page({
|
|
|
// duration: 2000
|
|
|
// });
|
|
|
},
|
|
|
+ export() {
|
|
|
+ var that = this;
|
|
|
+ const { nickName } = wx.getStorageSync('userInfo');
|
|
|
+ const unionid = wx.getStorageSync('unionid');
|
|
|
+ let exportData = {
|
|
|
+ hotel: this.data.hotel?this.data.hotel:'0',
|
|
|
+ room: this.data.room?this.data.room:'0',
|
|
|
+ userId: nickName?nickName:'0',
|
|
|
+ id2: unionid?unionid:'0',
|
|
|
+ }
|
|
|
+ if (!that.data.intervalId1) {
|
|
|
+ that.data.intervalId1 = setInterval(() => {
|
|
|
+ wx.request({
|
|
|
+ url:`${homeApi}/system/constitutionDiagnosis/export`,
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json', // 默认值
|
|
|
+ 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
|
|
|
+ },
|
|
|
+ // 参数
|
|
|
+ data: exportData,
|
|
|
+ responseType: "arraybuffer", // 该属性处理二进制数据(该属性一定要写)
|
|
|
+ success: res => {
|
|
|
+ console.log('res=='+JSON.stringify(res));
|
|
|
+ if(res.statusCode == 200){
|
|
|
+ if (that.data.intervalId3) {
|
|
|
+ clearInterval(that.data.intervalId3);
|
|
|
+ that.data.intervalId3 = null;
|
|
|
+ }
|
|
|
+ const fs = wx.getFileSystemManager(); // 获取全局唯一的文件管理器
|
|
|
+ fs.writeFile({ //写文件
|
|
|
+ // wx.env.USER_DATA_PATH是小程序提供的访问用户文件路劲的变量
|
|
|
+ filePath: wx.env.USER_DATA_PATH + '/'+ '体质问卷调查.xlsx', // 一般后端回返回文件名
|
|
|
+ data: res.data, // res.data就是获取到的二进制文件流
|
|
|
+ encoding: "binary", //二进制流文件必须是 binary
|
|
|
+ success(e) {
|
|
|
+ wx.openDocument({ // 打开文档
|
|
|
+ filePath: wx.env.USER_DATA_PATH + '/'+ '体质问卷调查.xlsx',
|
|
|
+ showMenu: true, // 显示右上角菜单
|
|
|
+ success: function(res) {
|
|
|
+ console.log("打开文件",res);
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ error(err){
|
|
|
+ console.log('export-err=='+err)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ },
|
|
|
onCloseResultsDialog() {
|
|
|
this.setData({ promptTextMessageFlag: false });
|
|
|
},
|
|
|
@@ -732,6 +788,10 @@ Page({
|
|
|
// clearInterval(this.data.intervalId2);
|
|
|
// this.data.intervalId2 = null; // 可选,但建议清除以避免潜在的错误
|
|
|
// }
|
|
|
+ if (that.data.intervalId3) {
|
|
|
+ clearInterval(that.data.intervalId3);
|
|
|
+ that.data.intervalId3 = null;
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
@@ -746,5 +806,29 @@ Page({
|
|
|
// clearInterval(this.data.intervalId2);
|
|
|
// this.data.intervalId2 = null; // 可选,但建议清除以避免潜在的错误
|
|
|
// }
|
|
|
+ if (that.data.intervalId3) {
|
|
|
+ clearInterval(that.data.intervalId3);
|
|
|
+ that.data.intervalId3 = null;
|
|
|
+ }
|
|
|
},
|
|
|
+
|
|
|
+ //取出arr2的value和arr1对应的remark和label项,取出的数据组装成一个字符串,加上'char10'
|
|
|
+ getFormattedString: function (arr1, arr2) {
|
|
|
+ // 检查 arr1 和 arr2 是否为非空数组
|
|
|
+ if (!arr1 || !arr2 || !Array.isArray(arr1) || arr1.length === 0 || !Array.isArray(arr2) || arr2.length === 0) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ let result = '';
|
|
|
+
|
|
|
+ arr1.forEach(value => {
|
|
|
+ const valueStr = value?value.toString():'';
|
|
|
+ const item = arr2.find(obj => obj.value == valueStr);
|
|
|
+ if (item) {
|
|
|
+ result += ` ${item.remark}、${item.label} char10`;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
});
|