This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
data-cy="ayaType"
|
||||
></v-select>
|
||||
</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-file-input
|
||||
v-model="uploadFile"
|
||||
@@ -21,7 +28,7 @@
|
||||
show-size
|
||||
></v-file-input
|
||||
><v-btn
|
||||
v-if="uploadFile && uploadFile.name && ayaType != 0"
|
||||
v-if="importable"
|
||||
:loading="uploading"
|
||||
color="primary"
|
||||
text
|
||||
@@ -53,11 +60,23 @@ export default {
|
||||
},
|
||||
uploadFile: [],
|
||||
ayaType: 8, //<<<<<<<<<<<<<-----------------------------CHANGE THIS TO ZERO WHEN DONE TESTING
|
||||
doImport: true,
|
||||
doUpdate: false,
|
||||
outputText: null,
|
||||
rights: window.$gz.role.defaultRightsObject(),
|
||||
uploading: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
importable() {
|
||||
return (
|
||||
(this.import || this.update) &&
|
||||
this.uploadFile &&
|
||||
this.uploadFile.name &&
|
||||
this.ayaType != 0
|
||||
);
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
//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);
|
||||
@@ -114,7 +133,9 @@ export default {
|
||||
this.uploading = true;
|
||||
const res = await window.$gz.api.post("import", {
|
||||
data: dat,
|
||||
atype: this.ayaType
|
||||
atype: this.ayaType,
|
||||
doImport: this.doImport,
|
||||
doUpdate: this.doUpdate
|
||||
});
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error);
|
||||
@@ -233,10 +254,45 @@ async function parseJSONFile(file) {
|
||||
//
|
||||
function cleanData(dat, atype) {
|
||||
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) {
|
||||
case 8:
|
||||
allowedProps.concat(["Name"]);
|
||||
case 8: //CUSTOMER
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user