This commit is contained in:
2026-01-26 20:54:48 +08:00
parent da6b22b783
commit 5047426c4d
8 changed files with 140 additions and 86 deletions
+1
View File
@@ -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)
+24
View File
@@ -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)
})
}
@@ -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"
/>
</template>
+48 -23
View File
@@ -1,5 +1,5 @@
<script setup>
import { onMounted, watch, ref ,defineProps} from "vue";
import { onMounted, watch, ref, defineProps, defineEmits } from "vue";
import { useI18n } from "vue-i18n";
import TomSelect from "tom-select";
@@ -7,47 +7,72 @@ import "tom-select/dist/css/tom-select.css";
const { t, locale } = useI18n();
const disable_backspace=ref()
const disable_backspace = ref();
function sele_tag_init() {
new TomSelect(disable_backspace.value, {
plugins: [ "remove_button"],
plugins: ["remove_button"],
persist: false,
createOnBlur: true,
create: true,
createOnBlur: true,
create: true,
// 自定义提示文本
render: {
no_results: function(data, escape) {
return '<div class="no-results">'+t("tagadder.not_fund_item")+'</div>';
},
loading: function(data, escape) {
return '<div class="loading">'+t("tagadder.loding")+'</div>';
},
option_create: function(data, escape) {
return '<div class="create">'+t("tagadder.add")+'<strong>' + escape(data.input) + '</strong></div>';
}
}
render: {
no_results: function (data, escape) {
return (
'<div class="no-results">' + t("tagadder.not_fund_item") + "</div>"
);
},
loading: function (data, escape) {
return '<div class="loading">' + t("tagadder.loding") + "</div>";
},
option_create: function (data, escape) {
return (
'<div class="create">' +
t("tagadder.add") +
"<strong>" +
escape(data.input) +
"</strong></div>"
);
},
},
});
}
defineProps({
const props = defineProps({
placeholder: {
type: String,
default: "",
},
})
modelValue: {
type: String,
default: "",
},
});
const emit = defineEmits(['update:modelValue'])
//const emit = defineEmits(['update:modelValue'])
onMounted(() => {
sele_tag_init();
});
const handleChange = (e) => {
emit("update:modelValue", e.target.value);
};
</script>
<template>
<div ref="example_wrapper">
<input type="text" ref="disable_backspace" value="" autocomplete="off" :placeholder="placeholder"/>
</div>
<div ref="example_wrapper">
<input
type="text"
ref="disable_backspace"
:value="modelValue"
@input="handleChange"
autocomplete="off"
:placeholder="placeholder"
/>
</div>
</template>
@@ -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({
<!-- 移除按钮 -->
</div>
</div>
<div class="text-end">{{ files.length }}/{{ maxFiles }}</div>
<div ref="dropzoneElement" class="dropzone"></div>
</div>
+1
View File
@@ -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",
+1
View File
@@ -66,6 +66,7 @@
"title": "标题",
"input_title": "输入订单标题",
"remarks": "备注",
"photo_remarks": "图片备注",
"remarks_text": "输入文字备注",
"purchase_channel": "采购途径",
"link": "链接",
@@ -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(
<label class="form-label"
>{{ t("purchase_addorder.remarks") }}
<span class="form-label-description"
>{{ textarea_len }}/{{ textarea_maxlen }}</span
>{{ submit_sheet.remark.length }}/{{
textarea_maxlen
}}</span
></label
>
<textarea
@@ -221,15 +221,8 @@ watch(
rows="6"
:placeholder="t('purchase_addorder.remarks_text')"
:maxlength="textarea_maxlen"
@input="textarea_change"
v-model="submit_sheet.remark"
></textarea>
<useDropzone
acceptedFiles="image/*"
uploadURL="/api/files/upload/image"
maxFiles="10"
ref="photos_hash"
></useDropzone>
</div>
</div>
@@ -247,7 +240,7 @@ watch(
name="url"
type="url"
class="form-control"
placeholder="http"
placeholder="https"
v-model="submit_sheet.link"
></textarea>
<div class="mb-3 mt-3">
@@ -269,7 +262,19 @@ watch(
<tagadder
:placeholder="t('purchase_addorder.add_style')"
v-model="submit_sheet.styles"
></tagadder>
<label class="form-label mt-3 mb-0">{{
t("purchase_addorder.photo_remarks")
}}</label>
<useDropzone
acceptedFiles="image/*"
uploadURL="/api/files/upload/image"
maxFiles="10"
ref="photos_hash"
></useDropzone>
</div>
<div class="mt-3">
@@ -299,7 +304,7 @@ watch(
<td class="text-secondary">{{ value.int }}</td>
<td class="text-secondary">{{ value.cost }}</td>
<td class="text-secondary">
{{ value.cost * value.int }}
{{ value.cost_t }}
</td>
<td class="text-secondary">
{{ currency_type[value.currency_type] }}
@@ -404,7 +409,9 @@ watch(
<label class="form-label required">{{
t("purchase_addorder.update_time")
}}</label>
<dateTimePicker></dateTimePicker>
<dateTimePicker
v-model="submit_sheet.update_time"
></dateTimePicker>
</div>
<div class="col-xl-4">
<label class="form-label">{{