Browse Source

feat:[模板管理][upadte]

master
luojie 13 hours ago
parent
commit
3a95a23d45
11 changed files with 111 additions and 46 deletions
  1. +9
    -0
      src/api/template/index.js
  2. +3
    -1
      src/components/Template/BaseInfoFormPcakge.vue
  3. +1
    -1
      src/components/Template/CustomTable.vue
  4. +33
    -12
      src/components/Template/HandleFormItem.vue
  5. +1
    -1
      src/components/Template/Step.vue
  6. +2
    -0
      src/utils/eventBus.js
  7. +18
    -11
      src/views/business/comps/template/TemplateTable.vue
  8. +22
    -5
      src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue
  9. +9
    -9
      src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue
  10. +11
    -4
      src/views/business/comps/template/mixins/templateMixin.js
  11. +2
    -2
      vue.config.js

+ 9
- 0
src/api/template/index.js View File

@ -7,4 +7,13 @@ export const getReagentList = (params) => {
method: 'get',
params
})
}
//获取最新的sn号
export const getLatestSn = (params) => {
return request({
url: '/system/business/public/getSn',
method: 'get',
params
})
}

+ 3
- 1
src/components/Template/BaseInfoFormPcakge.vue View File

@ -243,6 +243,7 @@ export default {
this.$set(this.errors, key, false);
}
},
//
updateFormData(key, value) {
this.formFields[key] = value;
//
@ -250,6 +251,7 @@ export default {
this.$set(this.errors, key, false);
}
},
//
batchUpdateFormData(data) {
Object.keys(data).forEach(key => {
this.formFields[key] = data[key];
@ -467,7 +469,7 @@ export default {
});
},
//
getDirectFormData() {
getFilledFormData() {
return this.formFields;
},
getFormDataByKey(key) {

+ 1
- 1
src/components/Template/CustomTable.vue View File

@ -192,7 +192,7 @@ export default {
this.headerSelectFields = headerSelectObj;
},
//
getDirectFormData() {
getFilledFormData() {
return {
stepTableFormData: [...this.localDataSource],
headerSelectFields: this.headerSelectFields,

+ 33
- 12
src/components/Template/HandleFormItem.vue View File

@ -33,7 +33,7 @@
</div>
<!-- qc才能操作 -->
<div class="handle-row" v-if="isShowHandle()">
<el-checkbox class="ml-5"></el-checkbox>
<el-checkbox class="ml-5" @change="onCheckboxChange"></el-checkbox>
<div @mouseenter="onMouseEnter" @mouseleave="onMouseLeave">
<Question class="handle-icon" :class="getQuestionColor()" />
</div>
@ -75,6 +75,7 @@
<script>
import Question from "./icons/Question.vue";
import DecimalInput from "./DecimalInput.vue";
import { EventBus } from "@/utils/eventBus"
export default {
components: {
Question,
@ -152,6 +153,17 @@ export default {
//gray green 绿 orange
return "green"
},
//
onCheckboxChange(val) {
//
EventBus.$emit('onModifyRecord', {
timestamp: new Date().toLocaleString(),
oldValue: this.oldValue,
newValue: val,
});
// this.$emit('input', val);
// this.$emit('change', val);
},
//
onInputChange(val) {
const value = val !== undefined ? val : this.inputValue;
@ -180,24 +192,33 @@ export default {
}
const {templateStatus} = this.$store.state.template;
//
if (this.inputValue !== this.oldValue && templateStatus === "actFill") {
if (templateStatus === "actFill") {
//
try {
// const passwordResult = await this.$prompt('', '', {
// confirmButtonText: '',
// cancelButtonText: '',
// inputType: 'password',
// inputPattern: /.+/,
// inputErrorMessage: '',
// zIndex: 10000,
// });
//
if(this.oldValue && this.oldValue !== this.inputValue){
const passwordResult = await this.$prompt('请输入密码以确认修改', '密码验证', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'password',
inputPattern: /.+/,
inputErrorMessage: '请输入密码',
zIndex: 10000,
});
}
this.$emit("onModifyRecord", {
timestamp: new Date().toLocaleString(),
oldValue: this.oldValue,
value: this.inputValue,
title:this.oldValue?"修改记录":"填写",
field:"试验基本信息-其他信息"
})
//
this.oldValue = this.inputValue; //
this.$emit("blur", val);
this.$emit('input', this.inputValue);
this.$emit("change", val);
//
await this.saveModificationRecord();
// await this.saveModificationRecord();
} catch {
//
this.inputValue = this.oldValue;

+ 1
- 1
src/components/Template/Step.vue View File

@ -254,7 +254,7 @@ export default {
},
//
getDirectFormData() {
getFilledFormData() {
return this.steps.map(step => ({
type: step.type,
...step.formData

+ 2
- 0
src/utils/eventBus.js View File

@ -0,0 +1,2 @@
import Vue from 'vue'
export const EventBus = new Vue()

+ 18
- 11
src/views/business/comps/template/TemplateTable.vue View File

@ -2,12 +2,13 @@
<div class="template-table">
<!-- <SP001 v-if="sn == 'SP0012'" />
<SWYPFXRYPZB v-if="sn == 'SP001'" /> -->
<component ref="templateComponent" :is="getTemplateComponent()" :templateData="templateData" :fillType="fillType">
</component>
<component ref="templateComponent" :is="getTemplateComponent()" :templateData="templateData" :fillType="fillType">
</component>
</div>
</template>
<script>
import { EventBus } from "@/utils/eventBus"
//
import SP001 from './comps/sp/SP001';
import SWYPFXRYPZB from "./comps/sp/SWYPFXRYPZB.vue";
@ -22,9 +23,9 @@ import MJYLQSQD from "./comps/gy/MJYLQSQD.vue";
export default {
name: "TemplateTable",
components: {
MJYLQSQD,SYWZPZJHB,
SP001,SWYPFXRYPZB ,Demo,SWYPFXCBYPZB,SWYPBQGZYZBB,SWYPNBGZYZBB,IndexDBDemo
components: {
MJYLQSQD, SYWZPZJHB,
SP001, SWYPFXRYPZB, Demo, SWYPFXCBYPZB, SWYPBQGZYZBB, SWYPNBGZYZBB, IndexDBDemo
},
props: {
sn: {
@ -37,11 +38,11 @@ export default {
},
templateData: {
type: Object,
default: () => {},
default: () => { },
},
},
computed: {
templateComponentMap() {
if (!this.componentMap) {
this.componentMap = {
@ -61,7 +62,7 @@ export default {
sn: {
immediate: true,
handler(v) {
console.log(v,"sn")
console.log(v, "sn")
}
}
},
@ -71,17 +72,23 @@ export default {
};
},
mounted() {
console.log(this.fillType,"fillType")
EventBus.$on('onModifyRecord', (data) => {
this.$emit("onModifyRecord", data)
})
},
beforeDestroy() {
//
EventBus.$off('onModifyRecord')
},
methods: {
async getFormData() {
return await this.$refs.templateComponent.getFormData();
},
getResource(){
getResource() {
return this.$refs.templateComponent.getResource();
},
getTemplateComponent() {
return this.templateComponentMap[this.sn]
return this.templateComponentMap[this.sn]
},
}
};

+ 22
- 5
src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue View File

@ -37,6 +37,7 @@ import TableList from "@/components/Template/Table";
import Step from "@/components/Template/Step";
import templateMixin from "../../mixins/templateMixin";
import CustomTable from '@/components/Template/CustomTable.vue';
import { getLatestSn } from '@/api/template';
export default {
name: "SWYPFXRYPZB",
@ -141,11 +142,11 @@ export default {
type: "cellItem",
label: this.$t('template.common.configurationTime'),
config: {
createTime: {
startDate: {
label: this.$t('template.common.startTime'),
type: "input",
},
endTime: {
endDate: {
label: this.$t('template.common.endTime'),
type: "input",
},
@ -169,7 +170,7 @@ export default {
type: "input",
subType: "span",
fillType: "preFill",
subKey: "targetCode1",
subKey: "targetCodeSn",
maxlength: 20
},
targetPreConcentration: {
@ -254,9 +255,26 @@ export default {
};
},
mounted() {
if(this.fillType === "actFill"){
this.getCode();
}
},
methods: {
//
async getCode(){
const result = await getLatestSn({
count: 1,
})
if(result.code == 200){
this.$refs.stepFormPackageRef.updateFormData("targetCodeSn",result.data)
}
},
//
getFilledFormData(){
return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"])
},
async getFormData() {
let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"]);
//resource
@ -279,11 +297,10 @@ export default {
//使
this.resource=tmpResource
console.log(this.resource, "resource")
return content;
},
async onSave() {
const formData = await this.getFormData();
const formData = await this.getFilledFormData();
console.log(formData, "formData")
},

+ 9
- 9
src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue View File

@ -785,16 +785,16 @@ export default {
return await this.validFormFields(refsToValidate);
},
getRealFormData(){
const baseData = this.$refs.baseInfoRef.getDirectFormData();
const conditionData = this.$refs.storageConditionRef.getDirectFormData();
const baseData = this.$refs.baseInfoRef.getFilledFormData();
const conditionData = this.$refs.storageConditionRef.getFilledFormData();
//
const ladderConfigsData = [];
if (this.formData.ladderConfigs && this.formData.ladderConfigs.length > 0) {
for (let i = 0; i < this.formData.ladderConfigs.length; i++) {
const ladderFormData = this.$refs[`ladderStepFormPackageRef_${i}`][0].getDirectFormData();
const ladderTableFormData = this.$refs[`ladderStepTableRef_${i}`][0].getDirectFormData();
const ladderStepData = this.$refs[`ladderStepRef_${i}`][0].getDirectFormData();
const ladderFormData = this.$refs[`ladderStepFormPackageRef_${i}`][0].getFilledFormData();
const ladderTableFormData = this.$refs[`ladderStepTableRef_${i}`][0].getFilledFormData();
const ladderStepData = this.$refs[`ladderStepRef_${i}`][0].getFilledFormData();
ladderConfigsData.push({
...ladderFormData,
@ -809,9 +809,9 @@ export default {
const paralleConfigsData = [];
if (this.formData.paralleConfigs && this.formData.paralleConfigs.length > 0) {
for (let i = 0; i < this.formData.paralleConfigs.length; i++) {
const paralleFormData = this.$refs[`paralleStepFormPackageRef_${i}`][0].getDirectFormData();
const paralleTableFormData = this.$refs[`paralleStepTableRef_${i}`][0].getDirectFormData();
const paralleStepData = this.$refs[`paralleStepRef_${i}`][0].getDirectFormData();
const paralleFormData = this.$refs[`paralleStepFormPackageRef_${i}`][0].getFilledFormData();
const paralleTableFormData = this.$refs[`paralleStepTableRef_${i}`][0].getFilledFormData();
const paralleStepData = this.$refs[`paralleStepRef_${i}`][0].getFilledFormData();
paralleConfigsData.push({
...paralleFormData,
@ -822,7 +822,7 @@ export default {
}
}
const remarkData = this.$refs.remarkRef.getDirectFormData();
const remarkData = this.$refs.remarkRef.getFilledFormData();
return {
...baseData,

+ 11
- 4
src/views/business/comps/template/mixins/templateMixin.js View File

@ -43,8 +43,15 @@ export default {
this.setTemplateData({});
},
methods: {
getResource() {
return this.resource;
//根据ref数组获取直接formData
getFilledFormDataByRefs(refArr = []){
let result = {};
refArr.map(ref => {
const refData = this.$refs[ref]?.getFilledFormData() || {};
result = { ...result, ...refData };
});
return result;
},
//统一校验form表单是否填写
async validFormFields(refArr = []) {
@ -96,9 +103,9 @@ export default {
//统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
onHandleBlur(fields) {
const { key, effectivePeriodUnit, effectivePeriod, codeSTD, targetStartSolution } = fields;
const { createTime } = this.formData;
const { startDate } = this.formData;
if (key === "effectivePeriod") {//统一处理有效周期失焦,计算失效事件,保证字段名不能变
const start = moment(createTime);
const start = moment(startDate);
const end = start.add(Number(effectivePeriod), effectivePeriodUnit).format("YYYY-MM-DD HH:mm:ss");
this.$refs.stepFormPackageRef.updateFormData("expireDate", end);
} else if (key === "codeSTD") {//起始编号STD失焦时,更新stepDataSource

+ 2
- 2
vue.config.js View File

@ -34,8 +34,8 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://localhost:8080`,
// target: `http://39.99.251.173:8080`,
// target: `http://localhost:8080`,
target: `http://39.99.251.173:8080`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save