store-management-app/src/pages/index/index.vue

382 lines
10 KiB
Vue
Raw Normal View History

2024-08-26 03:15:07 +00:00
<template>
2024-09-11 06:57:03 +00:00
<view class="content">
2024-10-21 02:44:55 +00:00
<!-- <navBar> 添加画作 </navBar> -->
2024-09-11 06:57:03 +00:00
<view class="container-box">
2024-10-21 10:19:09 +00:00
<div style="height: 160rpx">
<span style="font-weight: bold"> 已扫画筒号{{ state.pid }} </span>
<view style="display: flex; align-items: center">
<up-input
class="login-input"
placeholder="画家姓名/画作名称"
v-model="state.searchValue"
style="flex: 1; margin-right: 10rpx; height: 80rpx"
clearable
2024-10-21 06:48:25 +00:00
>
2024-10-21 10:19:09 +00:00
</up-input>
<up-button
2024-10-21 06:48:25 +00:00
style="
2024-10-21 10:19:09 +00:00
width: 120rpx;
height: 80rpx;
margin-top: 15rpx;
margin-left: 15rpx;
2024-10-21 06:48:25 +00:00
"
2024-10-21 10:19:09 +00:00
color="#EFC54E"
throttleTime="5"
:loading="loading"
@click="paintingList((state.page = 1))"
>搜索</up-button
2024-10-21 06:48:25 +00:00
>
2024-10-21 10:19:09 +00:00
</view>
</div>
<view style="flex: 1">
2024-10-22 01:50:21 +00:00
<up-list @scrolltolower="scrolltolower" style="max-height: 1000rpx">
2024-10-21 10:19:09 +00:00
<span>
2024-10-17 03:28:59 +00:00
<up-image
2024-10-21 10:19:09 +00:00
v-if="showNoResultImage"
src="../../static/empty.png"
2024-10-17 03:28:59 +00:00
width="100px"
height="100px"
2024-10-21 10:19:09 +00:00
style="
margin-left: 240rpx;
margin-top: 200rpx;
margin-bottom: 20px;
"
>
</up-image>
2024-10-17 03:28:59 +00:00
<span
2024-10-21 10:19:09 +00:00
v-if="showNoResultImage"
style="
font-weight: bold;
color: #bababa;
margin-left: 280rpx;
margin-top: 20rpx;
"
>暂无画作</span
2024-10-17 03:28:59 +00:00
>
2024-10-21 10:19:09 +00:00
</span>
<up-list-item
class="painting-box"
v-for="(painting, index) in state.tableData"
:key="index"
>
<span
style="display: flex; align-items: center; position: relative"
>
<up-image
:show-loading="true"
:src="painting.HdPic"
width="100px"
height="100px"
@click="enlarge(painting.HdPic)"
></up-image>
<span
style="
display: flex;
flex-direction: column;
margin-left: 10px;
flex: 1;
"
2024-10-17 03:28:59 +00:00
>
2024-10-21 10:19:09 +00:00
<div
style="
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
"
>
<span style="font-weight: bold">{{
painting.ArtworkName
}}</span>
<up-radio-group
v-model="painting.checked"
placement="right"
@change="groupChange"
>
<up-radio :name="painting.ArtworkUuid"></up-radio>
</up-radio-group>
</div>
<span style="color: #bcbcbc; font-size: 16px"
>画作编号{{ painting.Tfnum }}</span
>
<span style="color: #bcbcbc; font-size: 16px"
>画家编号{{ painting.Tnum }}</span
>
<span style="color: #bcbcbc; font-size: 16px"
>画家姓名{{ painting.ArtistName }}</span
>
<span style="color: #bcbcbc; font-size: 16px"
>平尺{{ painting.Ruler }}</span
>
</span>
2024-10-17 03:28:59 +00:00
</span>
2024-10-21 10:19:09 +00:00
</up-list-item>
</up-list>
</view>
</view>
<view class="button-container">
<up-button
style="width: 336rpx; margin: auto; height: 80rpx"
color="#BABABA"
throttleTime="5"
@click="backScan"
>取消</up-button
>
<up-button
style="width: 336rpx; margin: auto; height: 80rpx"
color="#EFC54E"
throttleTime="5"
:loading="loading"
:disabled="isButtonDisabled"
@click="doneSet"
v-if="hasPermission('APP-scanAdd')"
>
{{ buttonText }}</up-button
>
2024-09-11 06:57:03 +00:00
</view>
2024-10-17 03:28:59 +00:00
</view>
2024-08-26 03:15:07 +00:00
</template>
2024-09-11 06:57:03 +00:00
<script setup>
2024-09-19 01:38:53 +00:00
import { ref, reactive, onBeforeMount } from "vue";
import useToast from "@/hooks/toast/useToast.js";
2024-10-17 03:28:59 +00:00
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
2024-10-21 01:44:58 +00:00
import { creChangepainting, add, getRules } from "@/api/login.js";
2024-10-18 02:19:37 +00:00
import { closeWebview, hasPermission } from "../../../utils/index";
2024-10-17 03:39:04 +00:00
2024-09-19 01:38:53 +00:00
const { showMessage } = useToast();
const loading = ref(false);
2024-10-21 06:48:25 +00:00
const showNoResultImage = ref(false);
2024-09-19 07:40:39 +00:00
const isButtonDisabled = ref(false);
const buttonText = ref("确认");
2024-09-19 01:38:53 +00:00
const state = reactive({
id: "",
pid: "",
2024-10-17 03:28:59 +00:00
tableData: [],
page: 1,
pageSize: 10,
selectedUuid: "",
searchValue: "",
2024-09-19 01:38:53 +00:00
});
onLoad((options) => {
2024-10-21 06:48:25 +00:00
const token = window?.plus?.storage.getItem("token");
if (token) {
document.querySelector(".uni-page-head-hd").style.display = "none";
}
2024-10-17 03:28:59 +00:00
state.id = options.id;
state.pid = options.pid;
paintingList();
2024-10-21 01:44:58 +00:00
getBtngetRules();
2024-09-19 01:38:53 +00:00
});
2024-10-17 03:28:59 +00:00
const groupChange = (e) => {
state.tableData.forEach((item) => {
if (item.ArtworkUuid !== e) {
item.checked = "";
2024-09-20 08:27:19 +00:00
}
2024-10-17 03:28:59 +00:00
});
};
2024-09-19 01:38:53 +00:00
// 获取可添加的画作列表
const paintingList = async (param) => {
2024-10-17 03:28:59 +00:00
loading.value = true;
const res = await creChangepainting({
Tfnum: "",
ArtworkName: "",
Tnum: "",
ArtistName: "",
page: state.page,
pageSize: state.pageSize,
keywords: state.searchValue,
...param,
});
loading.value = false;
if (res.status === 0) {
if (res.data.Data !== null) {
state.tableData = res.data.Data.map((item) => {
return {
...item,
checked: "",
};
});
console.log(1111, state.tableData);
2024-10-21 03:45:56 +00:00
showNoResultImage.value = false;
2024-09-27 07:02:39 +00:00
} else {
2024-10-17 03:28:59 +00:00
state.tableData = [];
2024-10-21 06:48:25 +00:00
showNoResultImage.value = true;
2024-10-17 03:28:59 +00:00
showMessage({ type: "error", message: "查询失败,暂无画作!" });
2024-09-27 07:02:39 +00:00
}
2024-10-17 03:28:59 +00:00
} else {
showMessage({ type: "error", message: res.msg });
}
};
2024-09-27 07:02:39 +00:00
2024-09-20 08:27:19 +00:00
//添加画作
const doneSet = async () => {
loading.value = true;
const selectedPainting = state.tableData.find((item) => item.checked);
if (selectedPainting) {
2024-10-17 03:28:59 +00:00
const res = await add({
type: "add",
id: state.id,
pid: state.pid,
drawUid: selectedPainting.ArtworkUuid,
drawName: selectedPainting.ArtworkName,
drawerName: selectedPainting.ArtistName,
drawerUid: selectedPainting.ArtistUuid,
rulerNum: selectedPainting.Ruler,
drawThumbnail: selectedPainting.HdPic,
drawerNum: selectedPainting.Tnum, //画家编号
drawNum: selectedPainting.Tfnum,
});
if (res.status === 0) {
showMessage({ type: "sucess", message: "添加画作成功" });
isButtonDisabled.value = true;
buttonText.value = "已添加";
state.searchValue = "";
// 重新获取初始画作列表
paintingList({
page: 1,
pageSize: 10,
keywords: "",
});
2024-09-20 08:27:19 +00:00
} else {
2024-10-17 03:28:59 +00:00
showMessage({ type: "error", message: res.msg });
2024-09-20 08:27:19 +00:00
}
2024-10-17 03:28:59 +00:00
} else {
showMessage({ type: "error", message: "请先选择要添加的画作" });
}
loading.value = false;
2024-09-20 08:27:19 +00:00
};
2024-09-24 02:08:53 +00:00
//下拉刷新数据
const scrolltolower = async () => {
2024-09-27 07:02:39 +00:00
state.page = state.page + 1;
const res = await creChangepainting({
Tfnum: "",
ArtworkName: "",
Tnum: "",
ArtistName: "",
page: state.page,
pageSize: state.pageSize,
2024-10-17 03:28:59 +00:00
keywords: state.searchValue,
2024-09-27 07:02:39 +00:00
});
if (res.status === 0) {
2024-10-17 03:28:59 +00:00
if (res.data.Data !== null) {
const newData = res.data.Data.map((item) => {
return {
...item,
checked: "",
};
});
const uniqueData = newData.filter((newItem) => {
return !state.tableData.some(
(existingItem) => existingItem.ArtworkUuid === newItem.ArtworkUuid
);
});
state.tableData = state.tableData.concat(uniqueData);
}
} else {
showMessage({ type: "error", message: res.msg });
2024-09-27 07:02:39 +00:00
}
2024-09-24 02:08:53 +00:00
};
2024-09-30 01:51:29 +00:00
//点击照片预览
2024-10-17 03:28:59 +00:00
const enlarge = (src) => {
2024-09-30 01:51:29 +00:00
uni.previewImage({
2024-10-17 03:28:59 +00:00
urls: [src],
current: src,
2024-09-30 01:51:29 +00:00
});
2024-10-17 03:28:59 +00:00
};
const backScan = () => {
closeWebview();
};
2024-10-17 05:36:41 +00:00
const runTimeEnv = () => {
try {
if (plus) {
const currentWebView = plus.webview.getWebviewById("wv");
return currentWebView.RunTime === "app";
}
} catch (e) {
return false;
}
};
2024-10-21 01:44:58 +00:00
const getBtngetRules = async () => {
const res = await getRules({});
if (res.status === 0) {
const ruleBtn = res.data.MyButtonAuths?.map((button) => button.Url) || [];
uni.setStorageSync("ruleBtn", ruleBtn);
} else {
showMessage({ type: "error", message: res.msg });
}
};
2024-08-26 03:15:07 +00:00
</script>
2024-09-11 06:57:03 +00:00
<style lang="scss" scoped>
page {
background: url("@/static/bgp.png") no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
2024-10-21 10:19:09 +00:00
height: 100%;
2024-09-11 06:57:03 +00:00
box-sizing: border-box;
}
2024-10-21 10:19:09 +00:00
:deep(.u-radio) {
justify-content: end;
}
2024-08-26 03:15:07 +00:00
.content {
2024-10-21 10:19:09 +00:00
overflow-y: auto;
2024-08-26 03:15:07 +00:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
2024-10-21 10:19:09 +00:00
padding: 40rpx;
box-sizing: border-box;
width: 100%;
height: 100%;
2024-09-11 06:57:03 +00:00
.container-box {
2024-10-21 10:19:09 +00:00
margin-bottom: 20rpx;
width: 100%;
2024-09-11 06:57:03 +00:00
box-sizing: border-box;
height: 100%;
2024-10-21 10:19:09 +00:00
flex: 1;
padding: 40rpx;
2024-09-11 06:57:03 +00:00
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #fff;
2024-10-21 10:19:09 +00:00
.login-input {
width: 80%;
display: flex;
background-color: #f9f9f9;
margin-top: 20rpx;
padding: 32rpx 24rpx;
box-sizing: border-box;
height: 96rpx;
}
.painting-box {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
margin-top: 20rpx;
padding: 20rpx;
box-sizing: border-box;
background-color: #fff;
box-shadow: 0 0 6px rgba(219, 218, 218, 0.5);
}
2024-09-11 06:57:03 +00:00
}
2024-08-26 03:15:07 +00:00
}
2024-09-11 06:57:03 +00:00
.button-container {
2024-10-17 03:28:59 +00:00
display: flex;
justify-content: space-between;
width: 100%;
2024-10-21 10:19:09 +00:00
padding: 20rpx;
2024-10-17 03:28:59 +00:00
box-sizing: border-box;
background-color: #fff;
2024-10-21 12:08:18 +00:00
margin-bottom: 20rpx;
2024-10-22 01:50:14 +00:00
gap: 20rpx;
2024-10-17 03:28:59 +00:00
}
uni-button:after {
2024-10-21 03:24:13 +00:00
border: none;
}
2024-08-26 03:15:07 +00:00
</style>