From 5047426c4d16f1d1f805b207a5e078258cd4cc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Mon, 26 Jan 2026 20:54:48 +0800 Subject: [PATCH] up --- backend/routers/api.go | 1 + backend/routers/apiPurchase.go | 24 ++++++ .../src/components/dateTimePicker.vue | 10 ++- .../ops_vue_js/src/components/tagadder.vue | 73 ++++++++++++------ .../ops_vue_js/src/components/useDropzone.vue | 39 ++++------ frontent/ops_vue_js/src/i18n/en.json | 1 + frontent/ops_vue_js/src/i18n/zh-CN.json | 1 + .../src/views/purchase/addorder.vue | 77 ++++++++++--------- 8 files changed, 140 insertions(+), 86 deletions(-) create mode 100644 backend/routers/apiPurchase.go diff --git a/backend/routers/api.go b/backend/routers/api.go index e9bdbb6..186c24b 100644 --- a/backend/routers/api.go +++ b/backend/routers/api.go @@ -53,6 +53,7 @@ func ApiRoot(r *gin.RouterGroup) { ApiStatic(r.Group("/static")) ApiUser(r.Group("/users")) ApiFiles(r.Group("/files")) + ApiPurchase(r.Group("/purchase")) r.GET("/", func(ctx *gin.Context) { ReturnJson(ctx, "apiOK", nil) diff --git a/backend/routers/apiPurchase.go b/backend/routers/apiPurchase.go new file mode 100644 index 0000000..dddd030 --- /dev/null +++ b/backend/routers/apiPurchase.go @@ -0,0 +1,24 @@ +package routers + +import ( + "fmt" + + "github.com/gin-gonic/gin" +) + +func ApiPurchase(r *gin.RouterGroup) { + + r.POST("/addorder", func(ctx *gin.Context) { + isAuth, user, data := AuthenticationAuthority(ctx) + if isAuth { + + } else { + ReturnJson(ctx, "jsonErr", nil) + } + fmt.Println(isAuth) + fmt.Println(user) + fmt.Println(data) + ReturnJson(ctx, "apiErr", nil) + }) + +} diff --git a/frontent/ops_vue_js/src/components/dateTimePicker.vue b/frontent/ops_vue_js/src/components/dateTimePicker.vue index d4314ad..adcf5e2 100644 --- a/frontent/ops_vue_js/src/components/dateTimePicker.vue +++ b/frontent/ops_vue_js/src/components/dateTimePicker.vue @@ -31,6 +31,11 @@ const datatimepack_config = reactive({ }); const sele_data = reactive(); +const emit = defineEmits(['update:modelValue']) +const handleChange = (e) => { + //console.log(e) + emit("update:modelValue", e.target.value); +}; function getCurrentDateTime() { const now = new Date(); @@ -69,6 +74,8 @@ onMounted(() => { datatimepack_config.locale = locale.value == "zh-CN" ? "zh" : "en"; flatpickr(datatimepack.value, datatimepack_config); + + emit("update:modelValue", datatimepack_config.defaultDate); }); defineExpose({}); @@ -80,6 +87,7 @@ defineExpose({}); ref="datatimepack" type="datetime-local" class="form-control" - v-model="sele_data" + + @input="handleChange" /> diff --git a/frontent/ops_vue_js/src/components/tagadder.vue b/frontent/ops_vue_js/src/components/tagadder.vue index 2015164..e80dcec 100644 --- a/frontent/ops_vue_js/src/components/tagadder.vue +++ b/frontent/ops_vue_js/src/components/tagadder.vue @@ -1,5 +1,5 @@ diff --git a/frontent/ops_vue_js/src/components/useDropzone.vue b/frontent/ops_vue_js/src/components/useDropzone.vue index 7513b5d..f7de859 100644 --- a/frontent/ops_vue_js/src/components/useDropzone.vue +++ b/frontent/ops_vue_js/src/components/useDropzone.vue @@ -8,7 +8,7 @@ import "dropzone/dist/dropzone.css"; import { useUserStore } from "@/stores/user"; import "fslightbox"; -const lightbox = new FsLightbox(); +//var lightbox = new FsLightbox(); const userStore = useUserStore(); @@ -108,6 +108,9 @@ const initDropzone = () => { this.on("success", (file, response) => { //console.log("上传成功:", file, response); file.previewElement.addEventListener("click", function (e) { + //delete lightbox + const lightbox = new FsLightbox(); + //console.log(files) e.preventDefault(); e.stopPropagation(); @@ -116,7 +119,7 @@ const initDropzone = () => { //动态把文件载入灯箱 //先移除原有数据 - 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; @@ -131,23 +134,8 @@ const initDropzone = () => { } lightbox.open(dis_id); - - // 可以在这里实现: - // 1. 预览大图 - // 2. 显示文件详情 - // 3. 触发自定义操作 }); - //将后台接收到的url添加到文件列表 - // var t = { - // //uuid:file.upload.uuid, - // hash: response.return.hash, - // get_url: response.return.get, - // download_url: response.return.download, - // name: file.name, - // size: file.size, - // }; - var file_id = get_file_from_uuid(file.upload.uuid); if (file_id >= 0) { files[file_id]["hash"] = response.return.hash; @@ -179,23 +167,21 @@ const initDropzone = () => { }); this.on("addedfile", (file) => { //添加文件 - console.log(get_file_from_uuid(file.upload.uuid)); - //判断文件是否重复 - if (get_file_from_uuid(file.upload.uuid) <0) { - // //控制排序 需要从添加文件开始操作 + //控制排序 需要从添加文件开始操作 + + //限制文件数量 + if (files.length < prop.maxFiles) { var t = { uuid: file.upload.uuid, is_upload: false, }; files.push(t); - console.log(files); - return; + } else { + this.removeFile(file); } - //this.removeFile(file) - - + //console.log(files); }); this.on("sending", function (file, xhr, formData) { // 获取表单值并添加到 FormData @@ -326,6 +312,7 @@ defineExpose({ +
{{ files.length }}/{{ maxFiles }}
diff --git a/frontent/ops_vue_js/src/i18n/en.json b/frontent/ops_vue_js/src/i18n/en.json index 87d7430..bb0008d 100644 --- a/frontent/ops_vue_js/src/i18n/en.json +++ b/frontent/ops_vue_js/src/i18n/en.json @@ -66,6 +66,7 @@ "title": "Title", "input_title": "Enter order title", "remarks": "Remarks", + "photo_remarks": "Photos Remarks", "remarks_text": "Enter text notes", "purchase_channel": "Purchase Channel", "link": "Link", diff --git a/frontent/ops_vue_js/src/i18n/zh-CN.json b/frontent/ops_vue_js/src/i18n/zh-CN.json index 822f048..38ff795 100644 --- a/frontent/ops_vue_js/src/i18n/zh-CN.json +++ b/frontent/ops_vue_js/src/i18n/zh-CN.json @@ -66,6 +66,7 @@ "title": "标题", "input_title": "输入订单标题", "remarks": "备注", + "photo_remarks": "图片备注", "remarks_text": "输入文字备注", "purchase_channel": "采购途径", "link": "链接", diff --git a/frontent/ops_vue_js/src/views/purchase/addorder.vue b/frontent/ops_vue_js/src/views/purchase/addorder.vue index 3b8e2f9..576d24e 100644 --- a/frontent/ops_vue_js/src/views/purchase/addorder.vue +++ b/frontent/ops_vue_js/src/views/purchase/addorder.vue @@ -15,11 +15,10 @@ const userStore = useUserStore(); import { useRouter } from "vue-router"; const router = useRouter(); -import TomSelect from "tom-select"; import "tom-select/dist/css/tom-select.css"; +import { my_network_func } from "@/my_network_func"; const textarea_maxlen = 256; -const textarea_len = ref(0); const title_input_dom = ref(); @@ -75,6 +74,7 @@ const cost_sheet = reactive({ type: "1", int: 1, cost: 0.0, + cost_t: 0.0, currency_type: "1", }); @@ -82,15 +82,16 @@ function del_cost(key) { cost_sheet_tab.splice(key, 1); } function add_cost() { + // 四舍五入到2位小数 + // const fixed = parseFloat(newVal).toFixed(2); + // if (parseFloat(fixed) !== newVal) { + // cost_sheet.cost = parseFloat(fixed); + // } + + var t = parseFloat((cost_sheet.int * cost_sheet.cost).toFixed(2)); + cost_sheet.cost_t = t; + cost_sheet_tab.push(JSON.parse(JSON.stringify(cost_sheet))); - // var t = { - // type: cost_type[cost_sheet.type], - // int: cost_sheet.int, - // cost: cost_sheet.cost, - // currency_type: currency_type[cost_sheet.currency_type], - // }; - // cost_sheet_tab.push(t); - //console.log(t); } const submit_sheet = reactive({ @@ -99,7 +100,7 @@ const submit_sheet = reactive({ photos: [], link: "", part_name: "", - styles: [], + styles: "", costs: [], update_time: "", tracking_number: "", @@ -120,25 +121,22 @@ function submit_order() { return; } //载入图片哈希列表 + submit_sheet.photos = []; var photos = photos_hash.value.return_files(); for (var i = 0; i < photos.length; i++) { submit_sheet.photos.push(photos[i].hash); } + //载入价格表 + submit_sheet.costs = []; + for (var i = 0; i < cost_sheet_tab.length; i++) { + submit_sheet.costs.push(cost_sheet_tab[i]); + } + console.log(submit_sheet); -} - -function textarea_change(a) { - //console.log(textarea_val.value.length) - - textarea_len.value = submit_sheet.remark.length; - - // if(a.inputType=="insertText"){ - // textarea_len.value+=1; - // } - // if(a.inputType=="devareContentBackward"){ - // textarea_len.value-=1; - // } + my_network_func.postJson("/purchase/addorder", submit_sheet, (r) => { + console.log(r) + }); } function functionupdataTitle() { @@ -212,7 +210,9 @@ watch( - @@ -247,7 +240,7 @@ watch( name="url" type="url" class="form-control" - placeholder="http" + placeholder="https" v-model="submit_sheet.link" >
@@ -269,7 +262,19 @@ watch( + + + +
@@ -299,7 +304,7 @@ watch( {{ value.int }} {{ value.cost }} - {{ value.cost * value.int }} + {{ value.cost_t }} {{ currency_type[value.currency_type] }} @@ -404,7 +409,9 @@ watch( - +