mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2026-02-23 01:54:26 +08:00
v3.9.0【优化】typescript版本;【优化】App端消息;【优化】弹出层z-index;
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<!--
|
||||
* 生成
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-07-21 21:55:12
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-modal :open="visible" title="生成单号" ok-text="生成" cancel-text="关闭" @ok="onSubmit" @cancel="onClose">
|
||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }">
|
||||
<a-form-item label="业务">
|
||||
<a-input v-model:value="form.businessName" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="格式">
|
||||
<a-input v-model:value="form.format" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="循环周期">
|
||||
<a-input v-model:value="form.ruleType" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="上次产生单号">
|
||||
<a-input v-model:value="form.lastNumber" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="生成数量" name="count">
|
||||
<a-input-number v-model:value="form.count" />
|
||||
</a-form-item>
|
||||
<a-form-item label="生成结果">
|
||||
<a-textarea v-model:value="generateResult" :rows="2" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { message } from 'ant-design-vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { serialNumberApi } from '/@/api/support/serial-number-api';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import _ from 'lodash';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
|
||||
// emit
|
||||
const emit = defineEmits(['refresh']);
|
||||
defineExpose({
|
||||
showModal,
|
||||
});
|
||||
|
||||
// ----------------------- 表单 隐藏 与 显示 ------------------------
|
||||
// 是否展示
|
||||
const visible = ref(false);
|
||||
function showModal(data) {
|
||||
form.serialNumberId = data.serialNumberId;
|
||||
form.businessName = data.businessName;
|
||||
form.format = data.format;
|
||||
form.ruleType = data.ruleType;
|
||||
form.lastNumber = data.lastNumber;
|
||||
form.count = 1;
|
||||
generateResult.value = '';
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
// ----------------------- 表单 ------------------------
|
||||
const rules = {
|
||||
count: [{ required: true, message: '请输入数量' }],
|
||||
};
|
||||
|
||||
//生成结果
|
||||
const generateResult = ref('');
|
||||
|
||||
// 组件
|
||||
const formRef = ref();
|
||||
|
||||
const form = reactive({
|
||||
serialNumberId: -1,
|
||||
businessName: '',
|
||||
format: '',
|
||||
ruleType: '',
|
||||
lastNumber: -1,
|
||||
count: 1,
|
||||
});
|
||||
|
||||
function onSubmit() {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(async () => {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
let res = await serialNumberApi.generate(form);
|
||||
message.success('生成成功');
|
||||
generateResult.value = _.join(res.data, ', ');
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error', error);
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,147 @@
|
||||
<!--
|
||||
* 单号
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-07-21 21:55:12
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-card size="small" :bordered="false" :hoverable="true">
|
||||
<a-alert>
|
||||
<template v-slot:message>
|
||||
<h4>SerialNumber 单号生成器介绍:</h4>
|
||||
</template>
|
||||
<template v-slot:description>
|
||||
<pre>
|
||||
简介:SerialNumber是一个可以根据不同的日期、规则生成一系列特别单号的功能,比如订单号、合同号、采购单号等等。
|
||||
原理:内部有三种实现方式: 1) 基于内存锁实现 (不支持分布式和集群); 2) 基于redis锁实现 ; 3) 基于Mysql 锁for update 实现
|
||||
- 支持随机生成和查询生成记录
|
||||
- 支持动态配置
|
||||
</pre
|
||||
>
|
||||
</template>
|
||||
</a-alert>
|
||||
|
||||
<a-row justify="end">
|
||||
<TableOperator
|
||||
class="smart-margin-bottom5 smart-margin-top5"
|
||||
v-model="columns"
|
||||
:tableId="TABLE_ID_CONST.SUPPORT.SERIAL_NUMBER"
|
||||
:refresh="ajaxQuery"
|
||||
/>
|
||||
</a-row>
|
||||
|
||||
<a-table
|
||||
size="small"
|
||||
:loading="tableLoading"
|
||||
bordered
|
||||
class="smart-margin-top10"
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
rowKey="tag"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ record, column }">
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<div class="smart-table-operate">
|
||||
<a-button @click="generate(record)" v-privilege="'support:serialNumber:generate'" type="link">生成</a-button>
|
||||
<a-button @click="showRecord(record.serialNumberId)" v-privilege="'support:serialNumber:record'" type="link">查看记录</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<!---生成表单--->
|
||||
<SerialNumberGenerateFormModal ref="generateForm" @refresh="ajaxQuery" />
|
||||
<!---生成记录--->
|
||||
<SerialNumberRecordList ref="recordList" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import SerialNumberGenerateFormModal from './serial-number-generate-form-modal.vue';
|
||||
import SerialNumberRecordList from './serial-number-record-list.vue';
|
||||
import { serialNumberApi } from '/@/api/support/serial-number-api';
|
||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
|
||||
//------------------------ 表格渲染 ---------------------
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'serialNumberId',
|
||||
},
|
||||
{
|
||||
title: '业务',
|
||||
dataIndex: 'businessName',
|
||||
},
|
||||
{
|
||||
title: '格式',
|
||||
dataIndex: 'format',
|
||||
},
|
||||
{
|
||||
title: '循环周期',
|
||||
dataIndex: 'ruleType',
|
||||
},
|
||||
{
|
||||
title: '初始值',
|
||||
dataIndex: 'initNumber',
|
||||
},
|
||||
{
|
||||
title: '随机增量',
|
||||
dataIndex: 'stepRandomRange',
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
},
|
||||
{
|
||||
title: '上次产生单号',
|
||||
dataIndex: 'lastNumber',
|
||||
},
|
||||
{
|
||||
title: '上次产生时间',
|
||||
dataIndex: 'lastTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
width: 140,
|
||||
},
|
||||
]);
|
||||
|
||||
const tableLoading = ref(false);
|
||||
const tableData = ref([]);
|
||||
|
||||
async function ajaxQuery() {
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
let res = await serialNumberApi.getAll();
|
||||
tableData.value = res.data;
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(ajaxQuery);
|
||||
|
||||
// ------------------------------ 表格操作列: 生成 ------------------------------
|
||||
const generateForm = ref();
|
||||
function generate(record) {
|
||||
generateForm.value.showModal(record);
|
||||
}
|
||||
|
||||
// ------------------------------ 表格操作列: 查看结果 ------------------------------
|
||||
|
||||
const recordList = ref();
|
||||
function showRecord(serialNumberId) {
|
||||
recordList.value.showModal(serialNumberId);
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,115 @@
|
||||
<!--
|
||||
* 单号 记录
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-07-21 21:55:12
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-modal :open="visible" title="每日生成结果记录" width="60%" :footer="null" @cancel="onClose">
|
||||
<a-table size="small" :dataSource="tableData" :columns="columns" bordered :pagination="false">
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
<template v-if="column.dataIndex === 'successFlag'">
|
||||
<a-tag :color="text ? 'success' : 'error'">{{ text ? '成功' : '失败' }}</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.dataIndex === 'action'">
|
||||
<a-button @click="showDetail(record.operateLogId)" type="link">详情</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<div class="smart-query-table-page">
|
||||
<a-pagination
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
show-less-items
|
||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||
:defaultPageSize="queryForm.pageSize"
|
||||
v-model:current="queryForm.pageNum"
|
||||
v-model:pageSize="queryForm.pageSize"
|
||||
:total="total"
|
||||
@change="ajaxQuery"
|
||||
@showSizeChange="ajaxQuery"
|
||||
:show-total="(total) => `共${total}条`"
|
||||
/>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { serialNumberApi } from '/@/api/support/serial-number-api';
|
||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
|
||||
defineExpose({
|
||||
showModal,
|
||||
});
|
||||
|
||||
// ----------------------- 表单 隐藏 与 显示 ------------------------
|
||||
// 是否展示
|
||||
const visible = ref(false);
|
||||
|
||||
function showModal(id) {
|
||||
queryForm.serialNumberId = id;
|
||||
queryForm.pageNum = 1;
|
||||
queryForm.pageSize = 10;
|
||||
ajaxQuery();
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
// ----------------------- 表格 ------------------------
|
||||
const columns = reactive([
|
||||
{
|
||||
title: '单号ID',
|
||||
dataIndex: 'serialNumberId',
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
dataIndex: 'recordDate',
|
||||
},
|
||||
{
|
||||
title: '生成数量',
|
||||
dataIndex: 'count',
|
||||
},
|
||||
{
|
||||
title: '最后更新值',
|
||||
dataIndex: 'lastNumber',
|
||||
},
|
||||
{
|
||||
title: '上次生成时间',
|
||||
dataIndex: 'lastTime',
|
||||
},
|
||||
]);
|
||||
|
||||
const queryForm = reactive({
|
||||
serialNumberId: -1,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const tableLoading = ref(false);
|
||||
const tableData = ref([]);
|
||||
const total = ref(0);
|
||||
|
||||
async function ajaxQuery() {
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
let responseModel = await serialNumberApi.queryRecord(queryForm);
|
||||
const list = responseModel.data.list;
|
||||
total.value = responseModel.data.total;
|
||||
tableData.value = list;
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user