成功TypeError: this.xxx is undefined解决
<fieldset class="jzs-border">
<legend class="jzs-title">
男用药史({{ this.ListMedicationHistoryMan.length }})
</legend>
<div class="align-right" style="margin-bottom: 10px">
<el-button
type="primary"
@click="AddrowMedicationHistoryMan(ListMedicationHistoryMan)"
>新建行</el-button
>
<el-button type="primary" @click="AddBatchMedicationHistoryMan()"
>保存</el-button
>
</div>
<el-table
:data="ListMedicationHistoryMan"
element-loading-text="Loading"
border
fit
highlight-current-row
header-cell-style="color:#909399;font-weight:bold;"
>
<el-table-column prop="TakeTime" label="服用时间" align="center">
<template scope="scope">
<el-date-picker
v-model="scope.row.TakeTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间"
size="mini"
></el-date-picker>
</template>
</el-table-column>
<el-table-column prop="DrugCategory" label="药品类别" align="center">
<template scope="scope">
<el-select
v-model="scope.row.DrugCategory"
placeholder=""
size="mini"
>
<el-option
v-for="item in DrugCategoryOptions"
:key="item.DrugCategoryValue"
:label="item.DrugCategoryValue"
:value="item.DrugCategoryValue"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="DrugName" label="药品名称" align="center">
<template scope="scope">
<el-input size="mini" v-model="scope.row.DrugName"></el-input>
</template>
</el-table-column>
<el-table-column prop="Duration" label="持续时间" align="center">
<template scope="scope">
<el-input size="mini" v-model="scope.row.Duration"></el-input>
</template>
</el-table-column>
<el-table-column prop="Dose" label="剂量" align="center">
<template scope="scope">
<el-input
type="text"
oninput="value=value.replace(/[^\d]/g,'')"
maxlength="9"
v-model="scope.row.Dose"
placeholder=""
clearable
size="mini"
></el-input>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center">
<template scope="scope">
<el-input size="mini" v-model="scope.row.remark"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="100px">
<template slot-scope="scope">
<el-button
type="primary"
icon="el-icon-edit"
@click="AddrowMedicationHistoryMan(ListMedicationHistoryMan)"
circle
size="mini"
></el-button>
<el-button
type="danger"
icon="el-icon-delete"
@click="
DelrowMedicationHistoryMan(scope.$index, ListMedicationHistoryMan)
"
circle
size="mini"
></el-button>
</template>
</el-table-column>
</el-table>
</fieldset>
<script>
import { mapGetters } from "vuex";
import {
AddBatchContactHistory,
GetListContactHistory,
} from "@/api/ContactHistory";
import {
AddBatchMedicationHistory,
GetListMedicationHistory,
} from "@/api/MedicationHistory";
import {
getList_Name
} from "@/api/ContactHistorySpecificLinks";
export default {
filters: {},
data() {
return {
ListContactHistoryMan: [],
ListMedicationHistoryMan: [],
EggDevelopementDisorderNumber: "",
ContactWithSpecialTypesOfWorkOptions: [
{ ContactWithSpecialTypesOfWorkValue: "美容、美发" },
{ ContactWithSpecialTypesOfWorkValue: "农药" },
{ ContactWithSpecialTypesOfWorkValue: "皮革、皮毛加工" },
{ ContactWithSpecialTypesOfWorkValue: "鞋帽、服装加工" },
{ ContactWithSpecialTypesOfWorkValue: "印刷、造纸厂" },
{ ContactWithSpecialTypesOfWorkValue: "颜料、涂料、油漆" },
{ ContactWithSpecialTypesOfWorkValue: "其他" },
],
DrugCategoryOptions: [
{ DrugCategoryValue: "甲状腺相关药物" },
{ DrugCategoryValue: "溴隐亭" },
{ DrugCategoryValue: "保健品" },
{ DrugCategoryValue: "维生素A" },
{ DrugCategoryValue: "DHEA" },
{ DrugCategoryValue: "避孕药" },
{ DrugCategoryValue: "雌孕激素" },
{ DrugCategoryValue: "减肥药" },
{ DrugCategoryValue: "中药" },
{ DrugCategoryValue: "糖皮质激素" },
{ DrugCategoryValue: "抗抑郁药" },
{ DrugCategoryValue: "维甲酸" },
{ DrugCategoryValue: "其他药物" },
],
SpecificLinksOptions:[],
};
},
mounted() {
if (!this.LZBaseSession.EggDevelopementDisorderNumber) {
this.$router.push("/TopMain/CaseSel");
return;
}
this.EggDevelopementDisorderNumber = "LZ0015"; //临时
this.EggDevelopementDisorderNumber = this.LZBaseSession.EggDevelopementDisorderNumber;
this.fetchData_SpecificLinks();
this.FetchDataContactHistoryMan();
this.FetchDataMedicationHistoryMan();
},
computed: {
...mapGetters(["LZBaseSession", "name"]),
},
methods: {
//用药史部分
AddrowMedicationHistoryMan(tableData, event) {
tableData.push({
TakeTime: this.moment(new Date()).utcOffset(480).format( 'YYYY-MM-DD HH:mm:ss'),
});
},
DelrowMedicationHistoryMan(index, rows) {
rows.splice(index, 1);
},
FetchDataMedicationHistoryMan() {
let param = {
EggDevelopementDisorderNumber: this.EggDevelopementDisorderNumber,
Sex:"男",
};
GetListMedicationHistory(param).then((response) => {
debugger;
this.ListMedicationHistoryMan = response.Data;
});
},
AddBatchMedicationHistoryMan() {
//添加上卵障号
this.ListMedicationHistoryMan.forEach((element) => {
element.EggDevelopementDisorderNumber = this.EggDevelopementDisorderNumber;
element.AddMan = this.name;
element.Sex="男";
});
let params = this.ListMedicationHistoryMan;
AddBatchMedicationHistory(params).then((res) => {
this.$message({
type: "info",
message: res.Message,
});
});
},
},
};
</script>
调用这个FetchDataMedicationHistoryMan,提示TypeError: this.ListMedicationHistoryMan is undefined
多次检查,前端没有问题,这个变量也已经定义了,最后发现原来是后台接口出现了问题