客户健康页面优化

This commit is contained in:
xiezhijun 2021-01-25 00:22:56 +08:00
parent d0d4352eaf
commit ca989a6336
6 changed files with 225 additions and 45 deletions

View File

@ -78,6 +78,26 @@ public class CommonController {
} }
} }
/**
* 通用上传请求(无需登录认证)
*/
@PostMapping("/common/customerUploadFile")
public AjaxResult customerUploadFile(MultipartFile file) throws Exception {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
/** /**
* 本地资源通用下载 * 本地资源通用下载
*/ */

View File

@ -4,18 +4,21 @@ import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
import com.stdiet.common.core.page.TableDataInfo; import com.stdiet.common.core.page.TableDataInfo;
import com.stdiet.custom.domain.SysCustomer; import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysPhysicalSigns; import com.stdiet.custom.domain.SysPhysicalSigns;
import com.stdiet.custom.dto.request.CustomerInvestigateRequest; import com.stdiet.custom.dto.request.CustomerInvestigateRequest;
import com.stdiet.custom.service.ISysCustomerHealthyService;
import com.stdiet.custom.service.ISysCustomerService; import com.stdiet.custom.service.ISysCustomerService;
import com.stdiet.custom.service.ISysPhysicalSignsService; import com.stdiet.custom.service.ISysPhysicalSignsService;
import com.stdiet.system.service.ISysDictTypeService; import com.stdiet.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
/** /**
* 客户信息调查Controller * 客户相关信息调查Controller
* *
* @author xzj * @author xzj
* @date 2020-12-31 * @date 2020-12-31
@ -33,6 +36,9 @@ public class InvestigateController extends BaseController {
@Autowired @Autowired
private ISysDictTypeService dictTypeService; private ISysDictTypeService dictTypeService;
@Autowired
private ISysCustomerHealthyService sysCustomerHealthyService;
/** /**
* 建立客户信息档案 * 建立客户信息档案
*/ */
@ -68,6 +74,14 @@ public class InvestigateController extends BaseController {
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType)); return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
} }
/**
* 新增客户健康
*/
@PostMapping("/addCustomerHealthy")
public AjaxResult addCustomerHealthy(@RequestBody SysCustomerHealthy sysCustomerHealthy)
{
System.out.println(sysCustomerHealthy.getSex());
return toAjax(1);
}
} }

View File

@ -101,7 +101,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/custom/contract/file/**", "/custom/contract/file/**",
"/custom/wxUserInfo/wx/**", "/custom/wxUserInfo/wx/**",
"/custom/wxUserLog/wx/**", "/custom/wxUserLog/wx/**",
"/investigate/**" "/investigate/**",
"/common/customerUploadFile"
).anonymous() ).anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,

View File

@ -25,3 +25,12 @@ export function getDictData(dictType) {
method: 'get' method: 'get'
}) })
} }
// 新增客户健康
export function addCustomerHealthy(data) {
return request({
url: '/investigate/addCustomerHealthy',
method: 'post',
data: data
})
}

View File

@ -376,10 +376,15 @@ export default {
}, },
addCustomer() { addCustomer() {
if (this.submitFlag) { if (this.submitFlag) {
return; this.$message({
message: "请勿重复提交",
type: "warning",
});
return;
} }
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.submitFlag = true;
let cusMessage = Object.assign({}, this.form); let cusMessage = Object.assign({}, this.form);
cusMessage.bloodData = cusMessage.bloodData =
cusMessage.bloodData != null cusMessage.bloodData != null
@ -404,7 +409,8 @@ export default {
message: "", message: "",
type: "success", type: "success",
}); });
this.submitFlag = true; }else{
this.submitFlag = false;
} }
}); });
} else { } else {

View File

@ -26,6 +26,17 @@
<el-form-item label="手机号" prop="phone" maxlength="20"> <el-form-item label="手机号" prop="phone" maxlength="20">
<el-input type="number" v-model="form.phone" placeholder="请输入手机号" /> <el-input type="number" v-model="form.phone" placeholder="请输入手机号" />
</el-form-item> </el-form-item>
<el-form-item label="调理项目" prop="conditioningProjectId">
<el-select v-model="form.conditioningProjectId" placeholder="请选择">
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</div> </div>
<div v-show="stepArray[1]"> <div v-show="stepArray[1]">
@ -493,17 +504,28 @@
</div> </div>
<div v-show="stepArray[7]"> <div v-show="stepArray[7]">
<p class="p_title_1">调理项目和提交报告</p> <p class="p_title_1">体检报告</p>
<p class="p_title_2">1调理项目</p> <p class="p_title_2">1体检报告</p>
<el-form-item label="(1) 请选择调理项目" prop="conditioningProjectId"> <el-form-item label="(1) 请上传相应的体检报告" prop="fileList" class="margin-left">
<el-select v-model="form.conditioningProjectId" placeholder="请选择"> <el-upload style="margin-left: 20px;"
<el-option class="upload-demo"
v-for="dict in conditioningProjectIdOption" ref="upload"
:key="dict.dictValue" :action="upload.url"
:label="dict.dictLabel" :limit="upload.limit"
:value="parseInt(dict.dictValue)" :disabled="upload.isUploading"
/> :file-list="upload.fileList"
</el-select> :multiple="upload.multiple"
:on-change="handleFileChange"
:on-exceed="handleFileexceed"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:on-error="handleFileFail"
:data="upload.data"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<el-button style="margin-left: 10px;" size="small" @click="upload.fileList = []">重置</el-button>
<div slot="tip" class="el-upload__tip">提示最多可上传三份且每份文件不超过5M</div>
</el-upload>
</el-form-item> </el-form-item>
</div> </div>
<el-form-item style="text-align: center; margin: 30px auto" > <el-form-item style="text-align: center; margin: 30px auto" >
@ -522,7 +544,7 @@
> >
<el-button <el-button
type="primary" type="primary"
@click="addCustomer()" @click="submit()"
style="width: 40%" style="width: 40%"
v-show="stepActive == stepArray.length-1" v-show="stepActive == stepArray.length-1"
>提交数据</el-button >提交数据</el-button
@ -533,11 +555,17 @@
</section> </section>
</template> </template>
<script> <script>
import { getDictData } from "@/api/custom/customerInvestigation"; import { getDictData,addCustomerHealthy } from "@/api/custom/customerInvestigation";
const logo = require("@/assets/logo/st_logo.png"); const logo = require("@/assets/logo/st_logo.png");
export default { export default {
name: "index", name: "index",
data() { data() {
const checkReportFile = (rule, value, callback) => {
if (this.upload.fileList == null || this.upload.fileList.length === 0) {
return callback(new Error('请选择需要上传的体检报告'))
}
callback();
};
return { return {
logo, logo,
submitFlag: false, submitFlag: false,
@ -664,14 +692,14 @@ export default {
{"name":"洗洁剂","value": "10"},{"name":"化妆品","value": "11"} {"name":"洗洁剂","value": "10"},{"name":"化妆品","value": "11"}
], ],
conditioningProjectIdOption:[], conditioningProjectIdOption:[],
stepArray: [true,false,false,false,false,false,false,false], stepArray: [false,false,false,false,false,false,false,true],
stepActive: 0, stepActive: 7,
form: { form: {
name: null, name: "jun",
phone: null, phone: "152708980",
conditioningProjectId: 0, conditioningProjectId: 0,
sex: 1, sex: 1,
age: null, age: 18,
condiment:["1","5","9","6","1","3"], condiment:["1","5","9","6","1","3"],
otherCondiment:null, otherCondiment:null,
cookingStyle: ["8","9","4","11"], cookingStyle: ["8","9","4","11"],
@ -756,7 +784,26 @@ export default {
allergyFlag: 0, allergyFlag: 0,
allergySituation: null, allergySituation: null,
allergen:[], allergen:[],
otherAllergen:null otherAllergen:null,
fileNameList:[]
},
upload: {
//
isUploading: false,
//
url: process.env.VUE_APP_BASE_API + "/common/customerUploadFile",
//
headers: {},
//
data:{},
//
fileList:[],
//
limit: 3,
//
fileSize: 1024 * 1024 * 5,
//
multiple: true
}, },
rules: { rules: {
name: [ name: [
@ -783,33 +830,41 @@ export default {
message: "手机号格式不正确", message: "手机号格式不正确",
}, },
], ],
conditioningProjectId:[ conditioningProjectId:[
{ required: true, trigger: "blur", message: "请选择调理项目" } { required: true, trigger: "blur", message: "请选择调理项目" }
] ],
/*fileList:[
{required: true, trigger: "blur", validator: checkReportFile}
]*/
}, },
physicalSignsList: [], //
bloodDataList: [], arrayName:[
moistureDataList: [], "condiment","cookingStyle","cookingStyleRate", "washVegetablesStyle","lunchType","dinner","dietFlavor",
"snacks","waterType","waterHabit","drinksNum","drinkWineClassify","drinkWineAmount","smokeRate",
"workType","defecationTime","aerobicMotionClassify","anaerobicMotionClassify","anaerobicAerobicMotionClassify",
"motionField","sleepQuality", "familyIllnessHistory", "operationHistory", "longEatDrugClassify", "allergen", "fileNameList"
]
}; };
}, },
methods: { methods: {
addCustomer(){ submit(){
if (this.submitFlag) {
this.$message({
message: "请勿重复提交",
type: "warning",
});
return;
}
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
if(stepActive == stepArray.length-1){ this.submitFlag = true;
/*addCustomer(cusMessage).then((response) => { this.form.fileNameList = [];
if (response.code === 200) { if(this.upload.fileList.length > 0){
console.log("成功"); this.$refs.upload.submit();
this.$notify({ }else{
title: "提交成功", this.addCustomerHealthy();
message: "", }
type: "success",
});
this.submitFlag = true;
}
});*/
}
} else { } else {
this.$message({ this.$message({
message: "数据未填写完整", message: "数据未填写完整",
@ -818,6 +873,27 @@ export default {
} }
}); });
},
addCustomerHealthy(){
//
let cusMessage = Object.assign({}, this.form);
this.arrayName.forEach(function (item, index) {
cusMessage[item] = cusMessage[item] != null ? cusMessage[item].join(",") : null;
})
addCustomerHealthy(cusMessage).then((response) => {
if (response.code === 200) {
this.$notify({
title: "提交成功",
message: "",
type: "success",
});
}else{
this.submitFlag = false;
this.upload.isUploading = false;
}
});
console.log(cusMessage.cookingStyleRate);
console.log(cusMessage.washVegetablesStyle);
}, },
nextStep(step){ nextStep(step){
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
@ -841,7 +917,61 @@ export default {
getDictData(type).then(response => { getDictData(type).then(response => {
this.conditioningProjectIdOption = response.data; this.conditioningProjectIdOption = response.data;
}); });
} },
//
handleFileChange(file, fileList) {
/*console.log("------------")
let existFile = fileList.slice(0, fileList.length - 1).find(f => f.name === file.name);
if (existFile) {
this.$message({
message: "当前文件已经存在",
type: "warning",
});
fileList.pop();
}*/
let sizeFlag = file.size > this.upload.fileSize;
if (sizeFlag) {
this.$message({
message: "当前文件过大",
type: "warning",
});
fileList.pop();
}
this.upload.fileList = fileList;
},
//
handleFileexceed(file, fileList){
//console.log(this.upload.fileList.length);
this.$message({
message: "最多可上传"+ this.upload.limit +"份文件",
type: "warning",
});
},
//
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
//
handleFileSuccess(response, file, fileList) {
if(response != null && response.code === 200){
this.form.fileNameList.push(response.fileName);
if(this.form.fileNameList.length === this.upload.fileList.length){
//
this.addCustomerHealthy();
}
}else{
this.upload.isUploading = false;
this.submitFlag = false;
this.$message.error('文件上传失败');
}
},
//
handleFileFail(err, file, fileList){
this.$message.error('文件上传失败');
this.upload.isUploading = false;
this.submitFlag = false;
}
}, },
created() { created() {
this.getDict("conditioning_project"); this.getDict("conditioning_project");