This commit is contained in:
@@ -12,6 +12,13 @@
|
|||||||
data-cy="ayaType"
|
data-cy="ayaType"
|
||||||
></v-select>
|
></v-select>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
|
<v-checkbox v-model="doImport" :label="$ay.t('Import')"></v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
|
<v-checkbox v-model="doUpdate" :label="$ay.t('Update')"></v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
<v-file-input
|
<v-file-input
|
||||||
v-model="uploadFile"
|
v-model="uploadFile"
|
||||||
@@ -21,7 +28,7 @@
|
|||||||
show-size
|
show-size
|
||||||
></v-file-input
|
></v-file-input
|
||||||
><v-btn
|
><v-btn
|
||||||
v-if="uploadFile && uploadFile.name && ayaType != 0"
|
v-if="importable"
|
||||||
:loading="uploading"
|
:loading="uploading"
|
||||||
color="primary"
|
color="primary"
|
||||||
text
|
text
|
||||||
@@ -53,11 +60,23 @@ export default {
|
|||||||
},
|
},
|
||||||
uploadFile: [],
|
uploadFile: [],
|
||||||
ayaType: 8, //<<<<<<<<<<<<<-----------------------------CHANGE THIS TO ZERO WHEN DONE TESTING
|
ayaType: 8, //<<<<<<<<<<<<<-----------------------------CHANGE THIS TO ZERO WHEN DONE TESTING
|
||||||
|
doImport: true,
|
||||||
|
doUpdate: false,
|
||||||
outputText: null,
|
outputText: null,
|
||||||
rights: window.$gz.role.defaultRightsObject(),
|
rights: window.$gz.role.defaultRightsObject(),
|
||||||
uploading: false
|
uploading: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
importable() {
|
||||||
|
return (
|
||||||
|
(this.import || this.update) &&
|
||||||
|
this.uploadFile &&
|
||||||
|
this.uploadFile.name &&
|
||||||
|
this.ayaType != 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
async created() {
|
async created() {
|
||||||
//NOTE:Global is what is checked for initialize to show this form and at server to allow import
|
//NOTE:Global is what is checked for initialize to show this form and at server to allow import
|
||||||
this.rights = window.$gz.role.getRights(window.$gz.type.Global);
|
this.rights = window.$gz.role.getRights(window.$gz.type.Global);
|
||||||
@@ -114,7 +133,9 @@ export default {
|
|||||||
this.uploading = true;
|
this.uploading = true;
|
||||||
const res = await window.$gz.api.post("import", {
|
const res = await window.$gz.api.post("import", {
|
||||||
data: dat,
|
data: dat,
|
||||||
atype: this.ayaType
|
atype: this.ayaType,
|
||||||
|
doImport: this.doImport,
|
||||||
|
doUpdate: this.doUpdate
|
||||||
});
|
});
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
@@ -233,10 +254,45 @@ async function parseJSONFile(file) {
|
|||||||
//
|
//
|
||||||
function cleanData(dat, atype) {
|
function cleanData(dat, atype) {
|
||||||
var allowedProps = [];
|
var allowedProps = [];
|
||||||
//{"data":[{"id":8,"name":"Customer"},{"id":15,"name":"Head Office"},{"id":20,"name":"Part"},{"id":25,"name":"Project"},{"id":31,"name":"Unit"},{"id":32,"name":"Unit model"},{"id":33,"name":"Vendor"},{"id":62,"name":"Service rate"},{"id":63,"name":"Travel rate"},{"id":65,"name":"Part Assembly"},{"id":66,"name":"Part Warehouse"},{"id":72,"name":"Task group"}]}
|
//Note: convention here is any ID field that is linked object we want to support gets renamed here to replace *id with *Name, also Viz is acceptable both will be checked
|
||||||
|
//at front end it will attempt to match up but not create if not existing
|
||||||
switch (atype) {
|
switch (atype) {
|
||||||
case 8:
|
case 8: //CUSTOMER
|
||||||
allowedProps.concat(["Name"]);
|
allowedProps.concat([
|
||||||
|
"Name",
|
||||||
|
"Active",
|
||||||
|
"Notes",
|
||||||
|
"Wiki",
|
||||||
|
"CustomFields",
|
||||||
|
"Tags",
|
||||||
|
"WebAddress",
|
||||||
|
"AlertNotes",
|
||||||
|
"BillHeadOffice",
|
||||||
|
"HeadOfficeName",
|
||||||
|
"HeadOfficeViz",
|
||||||
|
"TechNotes",
|
||||||
|
"AccountNumber",
|
||||||
|
"ContractName",
|
||||||
|
"ContractViz",
|
||||||
|
"ContractExpires",
|
||||||
|
"Phone1",
|
||||||
|
"Phone2",
|
||||||
|
"Phone3",
|
||||||
|
"Phone4",
|
||||||
|
"Phone5",
|
||||||
|
"EmailAddress",
|
||||||
|
"PostAddress",
|
||||||
|
"PostCity",
|
||||||
|
"PostRegion",
|
||||||
|
"PostCountry",
|
||||||
|
"PostCode",
|
||||||
|
"Address",
|
||||||
|
"City",
|
||||||
|
"Region",
|
||||||
|
"Country",
|
||||||
|
"Latitude",
|
||||||
|
"Longitude"
|
||||||
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user