diff --git a/frontent/ops_vue_js/src/components/dateTimePicker.vue b/frontent/ops_vue_js/src/components/dateTimePicker.vue index 6990ea1..d4314ad 100644 --- a/frontent/ops_vue_js/src/components/dateTimePicker.vue +++ b/frontent/ops_vue_js/src/components/dateTimePicker.vue @@ -1,83 +1,85 @@ diff --git a/frontent/ops_vue_js/src/components/useDropzone.vue b/frontent/ops_vue_js/src/components/useDropzone.vue index 62570e8..7513b5d 100644 --- a/frontent/ops_vue_js/src/components/useDropzone.vue +++ b/frontent/ops_vue_js/src/components/useDropzone.vue @@ -13,27 +13,27 @@ const lightbox = new FsLightbox(); const userStore = useUserStore(); const dropzoneElement = ref(null); -let dropzoneInstance = null; +var dropzoneInstance = null; const files = reactive([]); function get_file_from_uuid(uuid) { if (files.length != 0) { - for(let i=0;i=0){ - files.splice(id, 1) + //devare files[uuid] + var id = get_file_from_uuid(uuid); + if (id >= 0) { + files.splice(id, 1); } } @@ -87,12 +87,12 @@ const initDropzone = () => { //addRemoveLinks: true, // 显示移除链接 dictDefaultMessage: t("dropzone.upload_drop_or_click"), dictFallbackMessage: t("dropzone.upload_browser_not_supported"), - dictFileTooBig: + dictFivarooBig: t("dropzone.upload_file_too_big") + "({{filesize}}MB). " + t("dropzone.upload_max_file_size") + "{{maxFilesize}}MB.", - dictInvalidFileType: t("dropzone.upload_invalid_file_type"), + dictInvalidFivarype: t("dropzone.upload_invalid_file_type"), dictResponseError: t("dropzone.upload_server_error") + "{{statusCode}}", //dictCancelUpload: t('dropzone.upload_cancel'), //dictUploadCanceled: t('dropzone.upload_canceled'), @@ -106,28 +106,28 @@ const initDropzone = () => { // 事件处理 init: function () { this.on("success", (file, response) => { - console.log("上传成功:", file, response); + //console.log("上传成功:", file, response); file.previewElement.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); // 处理点击事件 - console.log("缩略图被点击", file); + //console.log("缩略图被点击", file); //动态把文件载入灯箱 //先移除原有数据 - lightbox.props.sources.splice(0,lightbox.props.sources.length) + lightbox.props.sources.splice(0, lightbox.props.sources.length); - var dis_id=0; - var dis_id_t=0; - for (let i=0;i { // size: file.size, // }; - var file_id=get_file_from_uuid(file.upload.uuid) - if(file_id>=0) - { - files[file_id]["hash"]=response.return.hash; - files[file_id]["get_url"]=response.return.get; - files[file_id]["download_url"]=response.return.download; - files[file_id]["file_name"]=file.name; - files[file_id]["file_size"]=file.size; + var file_id = get_file_from_uuid(file.upload.uuid); + if (file_id >= 0) { + files[file_id]["hash"] = response.return.hash; + files[file_id]["get_url"] = response.return.get; + files[file_id]["download_url"] = response.return.download; + files[file_id]["file_name"] = file.name; + files[file_id]["file_size"] = file.size; - files[file_id]["is_upload"]=true; + files[file_id]["is_upload"] = true; - console.log(files) + //console.log(files) } //files.push(t) @@ -173,21 +172,30 @@ const initDropzone = () => { console.error("上传失败:", file.name, errorMessage); }); this.on("removedfile", (file) => { - console.log("remove:", file); + //console.log("remove:", file); //files.value = files.value.filter(f => f.name !== file.name) - remove_file_from_uuie(file.upload.uuid) - console.log(files) + remove_file_from_uuie(file.upload.uuid); + //console.log(files) }); this.on("addedfile", (file) => { //添加文件 - console.log("addfile", file); - //控制排序 需要从添加文件开始操作 - var t = { - uuid: file.upload.uuid, - is_upload: false, - }; - files.push(t); - console.log(files); + console.log(get_file_from_uuid(file.upload.uuid)); + + //判断文件是否重复 + if (get_file_from_uuid(file.upload.uuid) <0) { + // //控制排序 需要从添加文件开始操作 + var t = { + uuid: file.upload.uuid, + is_upload: false, + }; + files.push(t); + console.log(files); + return; + } + + //this.removeFile(file) + + }); this.on("sending", function (file, xhr, formData) { // 获取表单值并添加到 FormData @@ -229,6 +237,10 @@ const initDropzone = () => { // } // } +function return_files() { + return files; +} + // 组件挂载时初始化 onMounted(() => { initDropzone(); @@ -242,6 +254,10 @@ onUnmounted(() => { dropzoneInstance.destroy(); } }); + +defineExpose({ + return_files, +}); diff --git a/frontent/ops_vue_js/src/views/purchase/addorder.vue b/frontent/ops_vue_js/src/views/purchase/addorder.vue index b7dba01..3b8e2f9 100644 --- a/frontent/ops_vue_js/src/views/purchase/addorder.vue +++ b/frontent/ops_vue_js/src/views/purchase/addorder.vue @@ -2,6 +2,8 @@ import { onMounted, watch, ref, reactive } from "vue"; import { useI18n } from "vue-i18n"; +import MyOffcanvas from "@/components/MyOffcanvas.vue"; + import tagadder from "@/components/tagadder.vue"; import dateTimePicker from "@/components/dateTimePicker.vue"; @@ -18,7 +20,12 @@ import "tom-select/dist/css/tom-select.css"; const textarea_maxlen = 256; const textarea_len = ref(0); -const textarea_val = ref(); + +const title_input_dom = ref(); + +const photos_hash = ref(); + +const mos = ref(); const { t, locale } = useI18n(); @@ -44,7 +51,7 @@ const order_status = reactive({ 1: t("order_status.pending_order"), 2: t("order_status.order_placed"), 3: t("order_status.in_transit"), - 4: t("order_status.completed"), + 4: t("order_status.compvared"), 5: t("order_status.refund_requested"), 6: t("order_status.returning"), 7: t("order_status.refunded"), @@ -55,7 +62,7 @@ function update_order_status() { order_status["1"] = t("order_status.pending_order"); order_status["2"] = t("order_status.order_placed"); order_status["3"] = t("order_status.in_transit"); - order_status["4"] = t("order_status.completed"); + order_status["4"] = t("order_status.compvared"); order_status["5"] = t("order_status.refund_requested"); order_status["6"] = t("order_status.returning"); order_status["7"] = t("order_status.refunded"); @@ -86,19 +93,50 @@ function add_cost() { //console.log(t); } +const submit_sheet = reactive({ + title: "", + remark: "", + photos: [], + link: "", + part_name: "", + styles: [], + costs: [], + update_time: "", + tracking_number: "", + order_status: "1", +}); + function submit_order() { - console.log("up"); + if (submit_sheet.title == "") { + title_input_dom.value.classList.add("is-invalid"); + title_input_dom.value.addEventListener("input", function () { + if (this.value.trim() !== "") { + this.classList.remove("is-invalid"); + //this.removeEventListener('input'); + } + }); + + mos.value?.showAlert("danger", t("purchase_addorder.title"), 1000); + return; + } + //载入图片哈希列表 + var photos = photos_hash.value.return_files(); + for (var i = 0; i < photos.length; i++) { + submit_sheet.photos.push(photos[i].hash); + } + + console.log(submit_sheet); } function textarea_change(a) { //console.log(textarea_val.value.length) - textarea_len.value = textarea_val.value.length; + textarea_len.value = submit_sheet.remark.length; // if(a.inputType=="insertText"){ // textarea_len.value+=1; // } - // if(a.inputType=="deleteContentBackward"){ + // if(a.inputType=="devareContentBackward"){ // textarea_len.value-=1; // } } @@ -132,7 +170,7 @@ watch( cost_sheet.cost = parseFloat(fixed); } } - } + }, ); @@ -166,6 +204,8 @@ watch( class="form-control" name="example-text-input" :placeholder="t('purchase_addorder.title')" + v-model="submit_sheet.title" + ref="title_input_dom" />
@@ -182,12 +222,13 @@ watch( :placeholder="t('purchase_addorder.remarks_text')" :maxlength="textarea_maxlen" @input="textarea_change" - v-model="textarea_val" + v-model="submit_sheet.remark" >
@@ -202,13 +243,13 @@ watch( - + v-model="submit_sheet.link" + >
@@ -289,7 +331,7 @@ watch( @@ -374,7 +416,7 @@ watch( :placeholder=" t('purchase_addorder.input_tracking_number') " - value="" + v-model="submit_sheet.tracking_number" />
@@ -382,8 +424,8 @@ watch(