Lufaneng 9 months ago
parent 1abc380d5e
commit f0fc6c4c28

@ -2,7 +2,11 @@
<view class="container">
<!-- 顶部图片和标题 -->
<view class="header-section">
<image class="header-image" src="/static/imgs/indexImg.png" mode="aspectFill"></image>
<image
class="header-image"
src="/static/imgs/indexImg.png"
mode="aspectFill"
></image>
<view class="header-overlay">
<view class="header-title">生成电梯图纸</view>
<view class="header-subtitle">
@ -14,7 +18,10 @@
<!-- 选择图纸模板 -->
<view class="section">
<view class="section-title">选择图纸模板</view>
<uv-skeletons v-if="loading" :loading="loading" :skeleton="[
<uv-skeletons
v-if="loading"
:loading="loading"
:skeleton="[
{
type: 'flex',
num: 2,
@ -34,9 +41,16 @@
},
],
},
]"></uv-skeletons>
]"
></uv-skeletons>
<view class="template-grid" v-else>
<view class="template-item" :class="{ active: currentTemplate.id === item.id }" @click="selectTemplate(item)" v-for="item in templateList" :key="item.id">
<view
class="template-item"
:class="{ active: currentTemplate.id === item.id }"
@click="selectTemplate(item)"
v-for="item in templateList"
:key="item.id"
>
<view class="tag" v-if="item.price_cents">
¥ {{ item.price_cents / 100 }}
</view>
@ -49,20 +63,50 @@
<!-- 设置参数 -->
<view class="section" v-if="has_access">
<view class="section-title">设置参数</view>
<uv-skeletons v-if="params_loading" :loading="params_loading" :skeleton="[
<uv-skeletons
v-if="params_loading"
:loading="params_loading"
:skeleton="[
{
type: 'line',
num: 3,
gap: '20rpx',
},
]"></uv-skeletons>
]"
></uv-skeletons>
<view class="form" v-else>
<uv-form labelAlign="left" labelWidth="auto" labelPosition="left" :model="formField" :rules="rules" ref="form">
<uv-form-item :prop="item.name" :label="item.name + ''" v-for="item in currentTemplate.params?.filter(
<uv-form
labelAlign="left"
labelWidth="auto"
labelPosition="left"
:model="formField"
:rules="rules"
ref="form"
>
<uv-form-item
:prop="item.name"
:label="item.name + ''"
v-for="item in currentTemplate.params?.filter(
(item) => item.enabled
) || []">
<div class="required" v-if="item.required" style="color: #f12323;">*</div>
<uv-input @click="openPicker(item)" :readonly="item.type === 'select'" :type="item.type === 'number' ? 'digit' : 'text'" v-model="item.value" color="#000" border="bottom" :placeholderStyle="{ color: '#666778' }" placeholder="请输入"></uv-input>
) || []"
:key="item.name"
>
<div class="required" v-if="item.required" style="color: #f12323">
*
</div>
<uv-input
@click="openPicker(item)"
@input="handleInputChange(item)"
:readonly="item.type === 'select' || item.name === '土建图号'"
:type="item.type === 'number' ? 'digit' : 'text'"
v-model="item.value"
color="#000"
border="bottom"
:placeholderStyle="{ color: '#666778' }"
:placeholder="
item.name === '土建图号' ? '将根据土建图型号自动生成' : '请输入'
"
></uv-input>
</uv-form-item>
<!-- <uv-form-item prop="password" label="载重kg">
<uv-input
@ -125,20 +169,49 @@
</view>
<view class="section" v-else>
<div class="status">申请状态{{ get_access_status(currentTemplate.access_status) }}</div>
<uv-button size="small" v-if="currentTemplate.access_status !== 'pending'" @click="openApplyModal" text="申请权限" color="#3F70FF"></uv-button>
<div class="status">
申请状态{{ get_access_status(currentTemplate.access_status) }}
</div>
<uv-button
size="small"
v-if="currentTemplate.access_status !== 'pending'"
@click="openApplyModal"
text="申请权限"
color="#3F70FF"
></uv-button>
</view>
<!-- 底部按钮 -->
<view class="bottom-actions">
<uv-button :loading="generating" @click="modalRefOpen" text="生成图纸" color="#3F70FF"></uv-button>
<uv-button
:loading="generating"
@click="modalRefOpen"
text="生成图纸"
color="#3F70FF"
></uv-button>
<uv-button @click="viewHistory" text="查看记录"></uv-button>
</view>
<uv-modal ref="modalRef" showCancelButton content="确定生成图纸?" @confirm="confirmGenerate"></uv-modal>
<uv-modal ref="applyModalRef" showCancelButton title="申请权限" @confirm="confirmApply" @cancel="cancelApply">
<uv-modal
ref="modalRef"
showCancelButton
content="确定生成图纸?"
@confirm="confirmGenerate"
></uv-modal>
<uv-modal
ref="applyModalRef"
showCancelButton
title="申请权限"
@confirm="confirmApply"
@cancel="cancelApply"
>
<view class="apply-modal-content">
<view class="apply-label">申请理由</view>
<uv-textarea v-model="applyReason" placeholder="请输入申请理由" maxlength="200" count></uv-textarea>
<uv-textarea
v-model="applyReason"
placeholder="请输入申请理由"
maxlength="200"
count
></uv-textarea>
</view>
</uv-modal>
<uv-picker ref="picker" :columns="columns" @confirm="confirm"></uv-picker>
@ -146,7 +219,7 @@
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, nextTick } from "vue";
import {
onShow,
onLoad,
@ -162,28 +235,28 @@ import { usePermission } from "@/hooks/usePermission";
const authStore = useAuthStore();
const userStore = useUserStore();
const loading = ref(false);
const params_loading = ref(false)
const params_loading = ref(false);
const has_access = ref(false);
const applyModalRef = ref(null);
const applyReason = ref("");
const applyLoading = ref(false);
const get_access_status = access_status => {
let str = ''
if (access_status === 'none') {
str = '无权限'
} else if (access_status === 'pending') {
str = '等待审批...'
} else if (access_status === 'rejected') {
str = '已拒绝'
} else if (access_status === 'approved') {
str = '已同意'
const get_access_status = (access_status) => {
let str = "";
if (access_status === "none") {
str = "无权限";
} else if (access_status === "pending") {
str = "等待审批...";
} else if (access_status === "rejected") {
str = "已拒绝";
} else if (access_status === "approved") {
str = "已同意";
} else {
str = access_status
}
return str
str = access_status;
}
return str;
};
const modalRefOpen = () => {
if (!has_access.value) {
@ -193,22 +266,22 @@ const modalRefOpen = () => {
});
return;
}
let flag = false
let name
let flag = false;
let name;
currentTemplate.value.params
?.filter((item) => item.enabled)
.forEach((item) => {
if (item.required && !item.value) {
flag = true
name = item.name
flag = true;
name = item.name;
}
});
if (flag) {
uni.showToast({
title: `请检查【${name}`,
icon: 'none'
})
return
icon: "none",
});
return;
}
modalRef.value.open();
};
@ -226,6 +299,12 @@ const columns = ref([[]]);
const confirm = (val) => {
console.log(val);
currentParams.value.value = val.value[0];
//
if (currentParams.value.name === "土建图型号") {
nextTick(() => {
generateDrawingNumber();
})
}
};
//
@ -257,7 +336,7 @@ const confirmApply = async () => {
});
applyModalRef.value.close();
applyReason.value = "";
getList()
getList();
} catch (error) {
uni.showToast({
title: "申请失败,请重试",
@ -273,27 +352,70 @@ const cancelApply = () => {
applyReason.value = "";
};
//
const handleInputChange = (item) => {
//
if (item.name === "土建图型号") {
nextTick(() => {
generateDrawingNumber();
})
}
};
//
const generateDrawingNumber = () => {
const params = currentTemplate.value.params;
if (!params) return;
//
const modelParam = params.find((p) => p.name === "土建图型号");
const numberParam = params.find((p) => p.name === "土建图号");
if (!modelParam || !numberParam || !modelParam.value) return;
//
const now = new Date();
const year = now.getFullYear().toString().slice(-2); //
const month = (now.getMonth() + 1).toString().padStart(2, "0"); //
// 4+
const randomPart = generateRandomCode();
// GSE400-V25-10-0002A
numberParam.value = `${modelParam.value}-V${year}${month}-${randomPart}`;
};
// 4+1
const generateRandomCode = () => {
const numbers = Math.floor(Math.random() * 10000)
.toString()
.padStart(4, "0");
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const letter = letters.charAt(Math.floor(Math.random() * letters.length));
return numbers + letter;
};
const generating = ref(false);
const modalRef = ref(null);
const confirmGenerate = () => {
const params = {};
let flag = false
let name = ''
let flag = false;
let name = "";
currentTemplate.value.params
?.filter((item) => item.enabled)
.forEach((item) => {
if (item.required && !item.value) {
flag = true
name = item.name
flag = true;
name = item.name;
}
params[item.name] = item.value;
});
if (flag) {
uni.showToast({
title: `请检查【${name}`,
icon: 'none'
})
return
icon: "none",
});
return;
}
RPC.post("/template_create_task", {
template_id: currentTemplate.value.id,
@ -325,13 +447,15 @@ const getList = () => {
? JSON.parse(JSON.stringify(templateList.value[0]))
: {};
if (currentTemplate.value.has_access) {
params_loading.value = true
has_access.value = true
RPC.post('/template/detail', { id: currentTemplate.value.id }).then(res => {
currentTemplate.value.params = res?.params
}).finally(() => {
params_loading.value = false
params_loading.value = true;
has_access.value = true;
RPC.post("/template/detail", { id: currentTemplate.value.id })
.then((res) => {
currentTemplate.value.params = res?.params;
})
.finally(() => {
params_loading.value = false;
});
}
})
.finally(() => {
@ -344,12 +468,18 @@ const selectTemplate = (item) => {
currentTemplate.value = JSON.parse(JSON.stringify(item));
has_access.value = currentTemplate.value.has_access;
if (currentTemplate.value.has_access) {
params_loading.value = true
RPC.post('/template/detail', { id: currentTemplate.value.id }).then(res => {
currentTemplate.value.params = res?.params
}).finally(() => {
params_loading.value = false
params_loading.value = true;
RPC.post("/template/detail", { id: currentTemplate.value.id })
.then((res) => {
currentTemplate.value.params = res?.params;
//
nextTick(() => {
generateDrawingNumber();
})
})
.finally(() => {
params_loading.value = false;
});
}
};

Loading…
Cancel
Save