Edit Test Result

This commit is contained in:
saeid
2019-04-29 12:08:53 +04:30
parent f9600be080
commit c6f352c711
7 changed files with 267 additions and 165 deletions
+1
View File
@@ -5,6 +5,7 @@ const urls = {
login : "/login",
logout : "/logout",
storeMedicalCenter : "/MedicalCenters",
storeTestResult : "/TestResults",
listTestTypeName : "/TestTypes/ListNames",
getInputs : `/GetInputs`,
listOpertor : "/Users",
+39 -23
View File
@@ -40,7 +40,7 @@
<v-flex xs12 sm4 md3>
<v-text-field
name="autoclave"
v-model="form.autoclave_id"
v-model="formData.autoclave_id"
label="ID AutoClave"
color="black"
class="pa-2"
@@ -49,57 +49,54 @@
<v-flex xs12 sm4 md3>
<v-select
:items="result"
v-model="form.result"
v-model="formData.result"
label="Resualt"
color="black"
class="pa-2"
></v-select>
</v-flex>
<v-flex v-for="(item, key) in form.data" :key="key">
<v-flex :class="['pa-2', item.size]" v-for="(item, key) in form" :key="key">
<v-text-field
v-if="item.type == 'Text'"
v-model="item[item.name]"
v-model="formData[item.name]"
:label="item.name"
color="black"
class="pa-2"
></v-text-field>
<v-select
v-if="item.type == 'Select'"
:items="item.options"
v-model="item[item.name]"
v-model="formData[item.name]"
:label="item.name"
color="black"
class="pa-2"
item-text="title"
></v-select>
<v-container fluid v-if="item.type == 'Checkbox'">
<v-container fluid v-if="item.type == 'Checkbox'" >
<p>{{ item.name }}</p>
<v-checkbox
v-for="(optionValue, keyOption) in item.options"
:key="keyOption"
:label="optionValue.title"
v-model="item[item.name]"
v-model="formData[item.name]"
:value="optionValue.title"
></v-checkbox>
</v-container>
<template v-if="item.type == 'Form'">
<v-layout row wrap>
<h3>{{ item.name }}</h3>
<v-flex v-for="(children, keyChildren) in item.children" :key="keyChildren">
<v-flex :class="['pa-2', children.size]" v-for="(children, keyChildren) in item.children" :key="keyChildren">
<v-text-field
v-if="children.type == 'Text'"
v-model="children[children.name]"
v-model="formData[children.name]"
:label="children.name"
color="black"
class="pa-2"
></v-text-field>
<v-select
v-if="children.type == 'Select'"
:items="children.options"
v-model="children[children.name]"
v-model="formData[children.name]"
:label="children.name"
color="black"
class="pa-2"
item-text="title"
></v-select>
<v-container fluid v-if="children.type == 'Checkbox'">
@@ -108,7 +105,7 @@
v-for="(optionValue, keyOption) in children.options"
:key="keyOption"
:label="optionValue.title"
v-model="children[children.name]"
v-model="formData[children.name]"
:value="optionValue.title"
></v-checkbox>
</v-container>
@@ -121,7 +118,7 @@
<v-divider></v-divider>
</v-layout>
<v-layout align-center justify-center wrap class="px-5 mt-2">
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px">
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px" @click="submitForm">
<v-icon class="white--text mr-2 caption">fas fa-check</v-icon>
<span class="white--text">SAVE</span>
</v-btn>
@@ -144,14 +141,14 @@ export default {
result: ["Accept", "Reject"],
testTypeNames: [],
searchInput: "",
form: {
autoclave_id: "",
result: "",
data: []
},
form: [],
filter: {
name: "",
unique_code: ""
},
formData : {
autoclave_id: "",
result: "",
}
}),
created() {
@@ -165,9 +162,28 @@ export default {
async selectTestType() {
const result = await ApiService.post(urls.getInputs, this.filter);
if (result && result.status == 200) {
this.form.data = result.data.data;
this.form = result.data.data;
for (const key in result.data.data) {
if (result.data.data.hasOwnProperty(key)) {
if(result.data.data[key].type !== 'Form') {
this.formData[result.data.data[key].name] = '';
} else {
for (const keyForm in result.data.data[key].children) {
if (result.data.data[key].children.hasOwnProperty(keyForm)) {
this.formData[result.data.data[key].children[keyForm].name] = '';
}
}
}
}
}
}
}
},
async submitForm() {
const result = await ApiService.post(urls.storeTestResult, this.formData);
if (result && result.status == 200) {
this.$router.push({name: 'Dashboard'})
}
},
}
};
</script>
+14 -9
View File
@@ -48,6 +48,7 @@
item-text="state"
item-value="abbr"
label="Type"
v-bind="info.id !== 0 ? {disabled: true} : {disabled: false}"
v-model="info.type"
single-line
color="black"
@@ -61,8 +62,9 @@
:items="size"
item-text="state"
item-value="abbr"
label="Type"
label="Size"
v-model="info.size"
v-if="info.type !== 'Form'"
single-line
color="black"
class="pa-2"
@@ -150,6 +152,7 @@
item-value="abbr"
label="Type"
v-model="children.type"
v-bind="children.id !== 0 ? {disabled: true} : {disabled: false}"
single-line
color="black"
class="pa-2"
@@ -161,7 +164,8 @@
:items="size"
item-text="state"
item-value="abbr"
label="Type"
label="Size"
v-if="children.type !== 'Form'"
v-model="children.size"
single-line
color="black"
@@ -297,16 +301,17 @@ export default {
],
size: [
{ state: "not Selected", abbr: "" },
{ state: "2 as 12", abbr: "col-md-2" },
{ state: "3 as 12", abbr: "col-md-3" },
{ state: "4 as 12", abbr: "col-md-4" },
{ state: "6 as 12", abbr: "col-md-6" },
{ state: "8 as 12", abbr: "col-md-8" },
{ state: "10 as 12", abbr: "col-md-10" }
{ state: "2 as 12", abbr: "md2 xs12" },
{ state: "3 as 12", abbr: "md3 xs12" },
{ state: "4 as 12", abbr: "md4 xs12" },
{ state: "6 as 12", abbr: "md6 xs12" },
{ state: "8 as 12", abbr: "md8 xs12" },
{ state: "10 as 12", abbr: "md10 xs12" },
{ state: "10 as 12", abbr: "md12 xs12" },
],
rules: {
required: value => !!value || "Required."
}
},
};
},
created() {