branchErp/src/views/workbench/components/quickIndex.vue
2025-09-18 14:14:05 +08:00

881 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="index-container height-100 artwork-table" id="index-container">
<fl-table
:key="state.keyNum"
:config="state.tableConfig"
:refreshCount="state.tableConfig.refreshCount"
class="artwork-table"
@triggerRowActions="handleRowActions"
@triggerTableData="handleTableData"
>
<template #top-right>
<a-select
v-if="state.dep == 2 && checked"
v-model:value="ChainState"
style="width: 150px; margin-right: 20px"
placeholder="上链状态"
:options="state.linkOptions"
@change="handleLinkChange"
></a-select>
<a-switch
class="switch"
v-model:checked="checked"
@change="changeList"
/><span style="color: #764cf6; margin-right: 20px">{{
checked ? "已完成" : "未完成"
}}</span>
<a-button
type="primary"
shape="round"
class="fl-mr-sm"
style="width: 182px"
@click="handleExportArtwork"
:loading="state.btnLoading"
>导出画作数据</a-button
>
<a-button
type="primary"
shape="round"
class="fl-mr-sm"
style="width: 182px"
@click="handleBatchUpload"
:loading="state.btnLoading"
>批量上传</a-button
>
<a-button
type="primary"
shape="round"
style="width: 182px"
@click="handleCreate"
:loading="state.btnLoading"
>添加</a-button
>
</template>
<template v-slot:Signpic="Signpic">
<div class="drag-img">
<commonUpload
:type="'drag'"
:otherParams="state.otherParams"
:val="Signpic.text.Signpic"
:height="100"
:config="{
popover: true,
}"
@triggerUpload="(e) => handleUpload(Signpic.text, e, 'Signpic')"
/>
</div>
</template>
<template v-slot:DigiArtImg="DigiArtImg">
<div class="drag-img">
<commonUpload
:type="'drag'"
:otherParams="state.otherParams"
:val="DigiArtImg.text.DigiArtImg"
:height="100"
:config="{
popover: true,
}"
@triggerLayoutUpload="
(e) => handleLayoutUpload(e, 'DigiArtImg', DigiArtImg.text)
"
/>
</div>
</template>
<template v-slot:Sealpic="Sealpic">
<div class="drag-img">
<commonUpload
:type="'drag'"
:otherParams="state.otherParams"
:val="Sealpic.text.Sealpic"
:height="100"
:config="{
popover: true,
}"
@triggerUpload="(e) => handleUpload(Sealpic.text, e, 'Sealpic')"
/>
</div>
</template>
<template #pagination-left>
<div class="count">
<!-- <span v-show="!checked" style="margin-right: 20px"
>未完成数:{{ state.inCount }}</span
>
<span v-show="checked">已完完成数:{{ state.doneCount }}</span> -->
</div>
</template>
</fl-table>
<!-- -->
<a-modal
v-if="state.batchUploadModalVisible"
v-model:visible="state.batchUploadModalVisible"
:bodyStyle="{ height: '80vh' }"
class="fl-sf-modal"
width="60vw"
:closable="false"
:maskClosable="false"
:keyboard="false"
:footer="null"
>
<fl-artwork-batch-upload @triggerCloseModal="handleBatchUploadClose" />
</a-modal>
<a-modal
v-if="state.artworkModalVisible"
v-model:visible="state.artworkModalVisible"
width="90vw"
class="fl-modal-artwork"
:bodyStyle="{ height: '85vh' }"
:closable="false"
:maskClosable="false"
:keyboard="false"
:footer="null"
>
<fl-artwork-modal
:pageType="state.pageType"
:fatherData="state.rowData"
@triggerCloseModal="handleCloseModal"
></fl-artwork-modal>
</a-modal>
<fl-artwork-export-modal
v-if="state.exportDialogVisible"
:openCount="state.openCount"
:extraListParams="{ label: 'SaleStatusMul', value: [4, 5] }"
@triggerCloseModal="handleCloseExport"
/>
</div>
</template>
<script setup>
import { SearchOutlined } from "@ant-design/icons-vue";
import {
ref,
reactive,
onBeforeMount,
onMounted,
getCurrentInstance,
nextTick,
watch,
} from "vue";
import flTable from "@/components/layout/table/commonTable.vue";
import flArtworkModal from "./artworkmodal.vue";
import flArtworkBatchUpload from "../../artwork/components/batchupload.vue";
import flArtworkExportModal from "../../artwork/artworkexportmodal.vue";
import commonUpload from "@/components/layout/upload/commonUpload.vue";
import {
processError,
processSuccess,
processWarning,
} from "@/utils/helper/message";
import { onBeforeRouteUpdate, useRoute } from "vue-router";
import { downImg } from "@/utils/helper/fileDownload";
const currentInstance = getCurrentInstance();
const { $request } = currentInstance.appContext.config.globalProperties;
const checked = ref(false);
const isTab = ref(true);
const ChainState = ref(0);
const Source = ref(null);
console.log(useRoute());
const state = reactive({
otherParams: {
type: "image",
source: "artwork",
},
linkTypeMap: ["", "泰丰艺术区块链", "澄信链", "超级链"],
linkOptions: [
{
label: "所有",
value: 0,
},
{
label: "未上链",
value: 1,
},
{
label: "已部分上链",
value: 2,
},
{
label: "已完成上链",
value: 3,
},
],
action: import.meta.env.VITE_API_URL + "upload/img",
fileList: [
{
url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png",
},
],
ChainState: 0,
doneCount: 0,
inCount: 0,
dep: useRoute().name === "JzWorkBentch" ? 2 : 1,
openCount: 0,
exportDialogVisible: false,
btnLoading: false,
pageType: "create",
rowData: {},
artworkModalVisible: false,
batchUploadModalVisible: false,
keyNum: 0,
tableConfig: {
slotRight: true,
refreshCount: 0,
hasActionLoading: false,
listUrl: {
url: "artwork/my-aw-list",
params: [
{
label: "IsOver",
value: 1,
},
{
label: "ChainState",
value: ChainState,
},
{
label: "Source",
value: Source,
},
],
},
slotRight: true,
defaultSearch: {
fields: ["Keyword"],
placeholder: "在此处输入编号/姓名/推荐人/平尺",
},
columns: [
{
title: "作者姓名",
field: "artistShowCount",
},
{
title: "画作名称",
field: "ArtworkName",
},
{
title: "长度",
field: "Length",
},
{
title: "宽度",
field: "Width",
},
{
title: "平尺数",
field: "Ruler",
},
{
title: "商城编号",
field: "Tfnum",
},
{
type: "image",
title: "小图",
field: "HdPic",
},
{
title: "操作",
width: 140,
align: "center",
actions: [
{
actionType: "wutong",
hasLoading: true,
label: "泰丰艺术区块链上链",
type: "label",
permission: "wutong",
show: "[%=WtState%]===1",
actionLoadingField: "wutong",
},
{
actionType: "super",
label: "超级链上链",
hasLoading: true,
type: "label",
permission: "chaoji",
show: "[%=BaiduState%]===1",
actionLoadingField: "super",
},
{
actionType: "chengxin",
label: "澄信链上链",
hasLoading: true,
type: "label",
permission: "chengxin",
show: "[%=Changchainstate%]===1",
actionLoadingField: "chengxin",
},
{
actionType: "createBook",
label: "下载证书",
permission: "quick-work-download",
type: "label",
show: "[%=WtState%]===2&&[%=Changchainstate%]===2&&[%=BaiduState%]===2",
},
{
actionType: "modal_view",
label: "详情",
type: "label",
},
// {
// actionType: "delete",
// label: "删除",
// type: "label",
// tooltip: true,
// class: "color-danger",
// actionUrl: {
// url: "artwork/del",
// params: [
// {
// label: "ArtworkUuid",
// field: "ArtworkUuid",
// },
// ],
// },
// },
],
},
{
title: "人工",
actions: [
{
actionType: "update",
label: "完成",
type: "primary",
shape: "round",
actionUrl: {
url: "artwork/edit-aw-status",
params: [
{
type: "Array",
label: "ArtworkIds",
field: "Id",
},
{
label: "ActionType",
value: 2,
},
],
},
},
],
},
],
},
});
// 监听路由参数中的dep变化如果变化则重新请求列表
onBeforeRouteUpdate((to, from, next) => {
console.log(to.query);
handleRenderTable(to.query.dep);
Source.value = to.query.dep == 1 ? 2 : 1;
next();
});
onBeforeMount(() => {
handleRenderTable();
Source.value = state.dep == 1 ? 2 : 1;
});
onMounted(() => {});
// 上链状态更改
const handleLinkChange = (val) => {
state.tableConfig.refreshCount++;
};
// 上传
const handleBatchUpload = () => {
state.batchUploadModalVisible = true;
};
// 根据权限重新渲染表格
const handleRenderTable = (val) => {
// 获取query中的dep参数
let dep = val || state.dep;
console.log(dep);
if (dep == 1) {
state.tableConfig.columns = [
{
title: "作者姓名",
field: "artistShowCount",
},
{
title: "画作名称",
field: "ArtworkName",
},
{
title: "画作编号",
field: "Tfnum",
},
{
type: "image",
title: "画家提供图",
field: "HdPic",
},
{
type: "slot",
slotName: "DigiArtImg",
title: "数字化图",
field: "DigiArtImg",
},
{
type: "slot",
slotName: "Signpic",
title: "落款图",
field: "Signpic",
},
{
title: "人名章图",
field: "Sealpic",
type: "slot",
slotName: "Sealpic",
},
{
title: "预计时间",
field: "ScheduleTime",
},
{
title: "操作",
width: 140,
align: "center",
actions: [
{
actionType: "modal_view",
label: "详情",
type: "label",
},
],
},
{
title: "人工",
actions: [
{
actionType: "update",
label: "完成",
type: "primary",
shape: "round",
actionUrl: {
url: "artwork/edit-aw-status",
params: [
{
type: "Array",
label: "ArtworkIds",
field: "Id",
},
{
label: "ActionType",
value: 2,
},
],
},
},
],
},
];
} else if (dep == 2) {
state.tableConfig.columns = [
{
title: "作者姓名",
field: "artistShowCount",
},
{
title: "画作名称",
field: "ArtworkName",
},
{
title: "长度",
field: "Length",
},
{
title: "宽度",
field: "Width",
},
{
title: "平尺数",
field: "Ruler",
},
{
title: "画作编号",
field: "Tfnum",
},
{
type: "image",
title: "小图",
field: "HdPic",
},
{
title: "已上传点位数",
field: "BitMapNum",
},
{
title: "60",
field: "BmSixtyNum",
},
{
title: "200",
field: "BmTwoHundredNum",
},
{
title: "600",
field: "BmSixHundredNum",
},
{
title: "2000",
field: "BmTwoThousandNum",
},
{
title: "预计时间",
field: "ScheduleTime",
},
{
title: "操作",
width: 140,
align: "center",
actions: [
{
actionType: "wutong",
hasLoading: true,
label: "泰丰艺术区块链上链",
type: "label",
permission: "wutong",
show: "[%=WtState%]===1",
actionLoadingField: "wutong",
},
{
actionType: "iswutong",
label: "泰丰艺术区块链上链中",
type: "label",
permission: "wutong",
show: "[%=WtState%]===3",
},
{
actionType: "super",
label: "超级链上链",
hasLoading: true,
type: "label",
permission: "chaoji",
show: "[%=BaiduState%]===1",
actionLoadingField: "super",
},
{
actionType: "issuper",
label: "超级链上链中",
type: "label",
permission: "chaoji",
show: "[%=BaiduState%]===3",
},
{
actionType: "chengxin",
label: "澄信链上链",
hasLoading: true,
type: "label",
permission: "chengxin",
show: "[%=Changchainstate%]===1",
actionLoadingField: "chengxin",
},
{
actionType: "ischengxin",
label: "澄信链上链中",
type: "label",
permission: "chengxin",
show: "[%=Changchainstate%]===3",
},
{
actionType: "createBook",
label: "下载证书",
permission: "quick-work-download",
type: "label",
show: "State===2",
},
{
actionType: "modal_view",
label: "详情",
type: "label",
},
],
},
{
title: "人工",
actions: [
{
actionType: "update",
label: "完成",
type: "primary",
shape: "round",
actionUrl: {
url: "artwork/edit-aw-status",
params: [
{
type: "Array",
label: "ArtworkIds",
field: "Id",
},
{
label: "ActionType",
value: 2,
},
],
},
},
],
},
];
}
state.keyNum++;
};
// 切换状态
const changeList = (val) => {
if (val) {
state.tableConfig.listUrl.params = [
{
label: "IsOver",
value: 2,
},
{
label: "Source",
value: Source,
},
];
state.tableConfig.columns.pop();
} else {
state.tableConfig.listUrl.params = [
{
label: "IsOver",
value: 1,
},
{
label: "Source",
value: Source,
},
];
state.tableConfig.columns.push({
title: "人工",
actions: [
{
actionType: "update",
label: "完成",
type: "primary",
shape: "round",
actionUrl: {
url: "artwork/edit-aw-status",
params: [
{
type: "Array",
label: "ArtworkIds",
field: "Id",
},
{
label: "ActionType",
value: 2,
},
],
},
},
],
});
}
state.keyNum++;
state.tableConfig.refreshCount++;
};
const handleCreate = () => {
state.pageType = "create";
state.rowData = {};
state.artworkModalVisible = true;
};
const handleExportArtwork = () => {
state.exportDialogVisible = true;
state.openCount++;
};
const handleCloseExport = () => {
state.exportDialogVisible = false;
};
const handleLayoutUpload = ({ val, file }, field, rowData) => {
// 更新画作
let Rate = "";
if (file) {
let max = Math.max(file.width, file.height);
let min = Math.min(file.width, file.height);
Rate = (Math.floor((max / min) * 100) / 100).toFixed(2);
}
let url = "artwork/update-info-with-kv";
let params = {
ArtworkUuid: rowData.ArtworkUuid,
Column: field,
Value: val.ori_url || "",
Rate,
};
$request.HTTP.components.postDataByParams(url, params).then(
(res) => {
if (res.status === 0) {
processSuccess("操作成功");
} else {
processError(res.msg || "操作失败!");
}
state.tableConfig.refreshCount++;
},
(err) => {
processError(err.response.data.msg || "操作失败!");
}
);
};
const handleUpload = (v1, v2, Column) => {
// 更新画作
console.log(v1, v2, Column);
let params = { ArtworkUuid: v1.ArtworkUuid, Column: Column, Value: v2 };
$request.HTTP.artwork.artworkUpdate(params).then(
(res) => {
if (res.status === 0) {
processSuccess("操作成功");
} else {
processError(res.msg || "失败");
}
},
(err) => {
processError(err || "失败");
}
);
state.tableConfig.refreshCount++;
};
const handleTableData = (data, resData) => {
console.log(resData);
state.doneCount = resData.doneCount;
state.inCount = resData.inCount;
};
const handleContract = () => {};
const handleRowActions = (btnConfig, rowData) => {
if (btnConfig.actionType === "modal_view") {
state.pageType = "view";
state.rowData = rowData;
state.artworkModalVisible = true;
}
if (btnConfig.actionType === "wutong") {
goLink(rowData.ArtworkUuid, 1, btnConfig, rowData);
} else if (btnConfig.actionType === "super") {
goLink(rowData.ArtworkUuid, 3, btnConfig, rowData);
} else if (btnConfig.actionType === "chengxin") {
goLink(rowData.ArtworkUuid, 2, btnConfig, rowData);
} else if (btnConfig.actionType === "createBook") {
createBook(rowData);
}
};
// 上链接口
const goLink = async (uuid, type, btnConfig, rowData) => {
rowData[btnConfig.actionLoadingField] = true;
let params = { ArtworkUuid: uuid, Type: type };
await $request.HTTP.common.goLink(params).then(
(res) => {
if (res.status === 0) {
processSuccess(
"画作" +
res.data.Data.Tfnum +
state.linkTypeMap[res.data.Data.ChainType] +
"上链成功"
);
} else {
processError(res.msg || "失败");
}
delete rowData[btnConfig.actionLoadingField];
},
(err) => {
processError(err || "失败");
delete rowData[btnConfig.actionLoadingField];
}
);
state.tableConfig.refreshCount++;
};
// 生成证书
const createBook = (rowData) => {
let params = { ArtworkUuid: rowData.ArtworkUuid };
$request.HTTP.common.createBook(params).then(
async (res) => {
if (res.status === 0) {
processSuccess("操作成功");
await downImg(
res.data.CertTmUrl,
rowData.ArtistName + "-" + rowData.ArtworkName + "-证书"
);
} else {
processError(res.msg || "失败");
}
},
(err) => {
processError(err || "失败");
}
);
// state.keyNum++;
state.tableConfig.refreshCount++;
};
const handleCloseModal = (needRefresh) => {
if (needRefresh) {
state.tableConfig.refreshCount++;
}
state.artworkModalVisible = false;
};
const handleBatchUploadClose = () => {
state.tableConfig.refreshCount++;
state.batchUploadModalVisible = false;
};
</script>
<style scoped lang="scss">
.artwork-table :deep(.ant-table-thead th:first-child) {
border-radius: 23px 0px 0 0 !important;
}
.artwork-table :deep(.ant-table-thead th:last-child) {
border-radius: 0 23px 0 0 !important;
}
.avatar-uploader > .ant-upload {
width: 128px;
height: 128px;
}
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
.switch {
:deep(.ant-switch-handle::before) {
background-color: #764cf6;
}
:deep(.ant-switch-handle) {
top: 1px;
}
border: 1px #c9c0e2 solid;
background-color: #fff;
}
.ant-switch-checked {
background-color: #764cf6;
:deep(.ant-switch-handle::before) {
background-color: #fff;
}
}
.index-container {
position: relative;
}
.count {
font-size: 16px;
font-weight: 500;
}
:deep(.drag-img .preview-image .ant-image) {
width: 100px;
height: 100px;
}
:deep(.drag-img .ant-image-img) {
width: 100px;
height: 100px !important;
}
</style>