第一次提交
This commit is contained in:
337
src/views/yunxinwei/alarm/components/edit.vue
Normal file
337
src/views/yunxinwei/alarm/components/edit.vue
Normal file
@@ -0,0 +1,337 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑' : '新建'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="选择设备" name="equipmentCode">
|
||||
<EquipmentSelect
|
||||
dict-code="equipmentCode"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="报警类型" name="alarmType">
|
||||
<DictSelect
|
||||
dict-code="alarmType"
|
||||
v-model:value="form.alarmType"
|
||||
placeholder="选择报警类型"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="上传图片" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="1"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="备注" name="comments">-->
|
||||
<!-- <a-textarea-->
|
||||
<!-- :rows="4"-->
|
||||
<!-- :maxlength="200"-->
|
||||
<!-- placeholder="请输入备注"-->
|
||||
<!-- v-model:value="form.comments"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="处理状态" name="status">-->
|
||||
<!-- <a-radio-group v-model:value="form.status">-->
|
||||
<!-- <a-radio :value="0">未处理</a-radio>-->
|
||||
<!-- <a-radio :value="1">已处理</a-radio>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { EquipmentAlarm } from '@/api/apps/equipment/alarm/model';
|
||||
import {
|
||||
addEquipmentAlarm,
|
||||
updateEquipmentAlarm
|
||||
} from '@/api/apps/equipment/alarm';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: EquipmentAlarm | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<EquipmentAlarm>({
|
||||
id: undefined,
|
||||
equipmentCode: undefined,
|
||||
handleTime: undefined,
|
||||
alarmType: undefined,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
merchantCode: undefined
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择设备',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
alarmType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择报警类型',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
// status: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'number',
|
||||
// message: '请选择设备状态',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
// sortNumber: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'number',
|
||||
// message: '请输入排序号',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
// content: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请输入文章内容',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (content.value == '') {
|
||||
// return Promise.reject('请输入文字内容');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipmentAlarm(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentAlarmForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateEquipmentAlarm
|
||||
: addEquipmentAlarm;
|
||||
saveOrUpdate(equipmentAlarmForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
// images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
135
src/views/yunxinwei/alarm/components/search.vue
Normal file
135
src/views/yunxinwei/alarm/components/search.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<!-- <a-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :v-role="`superAdmin`"-->
|
||||
<!-- @click="add"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>新建</span>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button-->
|
||||
<!-- danger-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :v-role="`superAdmin`"-->
|
||||
<!-- @click="removeBatch"-->
|
||||
<!-- v-if="props.selection.length > 0"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <DeleteOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>批量删除</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="alarmType">报警类型</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { EquipmentAlarmParam } from '@/api/apps/equipment/alarm/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<EquipmentAlarmParam>({
|
||||
id: undefined,
|
||||
alarmType: '',
|
||||
equipmentCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
if (type.value == 'alarmType') {
|
||||
where.alarmType = searchText.value;
|
||||
where.equipmentCode = undefined;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
where.alarmType = undefined;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
listType.value = e.target.value;
|
||||
if (listType.value == 'all') {
|
||||
resetFields();
|
||||
}
|
||||
if (listType.value == 'onSale') {
|
||||
where.status = 0;
|
||||
}
|
||||
if (listType.value == 'offSale') {
|
||||
where.status = 1;
|
||||
}
|
||||
if (listType.value == 'soldOut') {
|
||||
where.stockTotal = 0;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
search();
|
||||
};
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
250
src/views/yunxinwei/alarm/index.vue
Normal file
250
src/views/yunxinwei/alarm/index.vue
Normal file
@@ -0,0 +1,250 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="电池报警">
|
||||
<div class="ele-text-secondary"> 电池报警记录。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<a @click="openEdit(record)">{{ record.equipmentCode }}</a>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageEquipmentAlarm,
|
||||
removeEquipmentAlarm,
|
||||
removeBatchEquipmentAlarm
|
||||
} from '@/api/apps/equipment/alarm';
|
||||
import type {
|
||||
EquipmentAlarm,
|
||||
EquipmentAlarmParam
|
||||
} from '@/api/apps/equipment/alarm/model';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode',
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '报警类型',
|
||||
dataIndex: 'alarmType',
|
||||
key: 'alarmType',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<EquipmentAlarm[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<EquipmentAlarm | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
// const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageEquipmentAlarm({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentAlarmParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: EquipmentAlarm) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
// const openInfo = (row?: EquipmentAlarm) => {
|
||||
// current.value = row ?? null;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: EquipmentAlarm) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeEquipmentAlarm(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipmentAlarm(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentAlarmIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
338
src/views/yunxinwei/fault/components/edit.vue
Normal file
338
src/views/yunxinwei/fault/components/edit.vue
Normal file
@@ -0,0 +1,338 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑' : '新建'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="选择设备" name="equipmentCode">
|
||||
<EquipmentSelect
|
||||
dict-code="equipmentCode"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="故障原因" name="faultType">
|
||||
<DictSelect
|
||||
dict-code="faultType"
|
||||
v-model:value="form.faultType"
|
||||
placeholder="选择故障原因"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="上传图片" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="1"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="备注" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="处理状态" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">未处理</a-radio>
|
||||
<a-radio :value="1">已处理</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { EquipmentFault } from '@/api/apps/equipment/fault/model';
|
||||
import {
|
||||
addEquipmentFault,
|
||||
updateEquipmentFault
|
||||
} from '@/api/apps/equipment/fault';
|
||||
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: EquipmentFault | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<EquipmentFault>({
|
||||
id: undefined,
|
||||
equipmentCode: undefined,
|
||||
handleTime: undefined,
|
||||
faultType: undefined,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
merchantCode: undefined
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择设备',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
faultType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择故障原因',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入文章内容',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == '') {
|
||||
return Promise.reject('请输入文字内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipmentFault(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentFaultForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateEquipmentFault
|
||||
: addEquipmentFault;
|
||||
saveOrUpdate(equipmentFaultForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
// images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
141
src/views/yunxinwei/fault/components/search.vue
Normal file
141
src/views/yunxinwei/fault/components/search.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
v-permission="'apps:equipment:save'"
|
||||
@click="add"
|
||||
>
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
v-if="props.selection.length > 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-radio-group v-model:value="listType" @change="handleTabs">-->
|
||||
<!-- <a-radio-button value="all">全部</a-radio-button>-->
|
||||
<!-- <a-radio-button value="onSale">出售中</a-radio-button>-->
|
||||
<!-- <a-radio-button value="offSale">已下架</a-radio-button>-->
|
||||
<!-- <a-radio-button value="soldOut">已售罄</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="faultType">故意原因</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { EquipmentFaultParam } from '@/api/apps/equipment/fault/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<EquipmentFaultParam>({
|
||||
id: undefined,
|
||||
faultType: '',
|
||||
equipmentCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
if (type.value == 'faultType') {
|
||||
where.faultType = searchText.value;
|
||||
where.equipmentCode = undefined;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
where.faultType = undefined;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// listType.value = e.target.value;
|
||||
// if (listType.value == 'all') {
|
||||
// resetFields();
|
||||
// }
|
||||
// if (listType.value == 'onSale') {
|
||||
// where.status = 0;
|
||||
// }
|
||||
// if (listType.value == 'offSale') {
|
||||
// where.status = 1;
|
||||
// }
|
||||
// if (listType.value == 'soldOut') {
|
||||
// where.stockTotal = 0;
|
||||
// }
|
||||
// emit('search', where);
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
290
src/views/yunxinwei/fault/index.vue
Normal file
290
src/views/yunxinwei/fault/index.vue
Normal file
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="故障电池">
|
||||
<div class="ele-text-secondary"> 故障电池上报记录。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="80" />
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<a @click="openEdit(record)">{{ record.equipmentCode }}</a>
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentFaultName'">
|
||||
{{ record.equipmentFaultName }}
|
||||
</template>
|
||||
<template v-if="column.key === 'isOnline'">
|
||||
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">异常</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="red">未处理</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="green">已处理</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageEquipmentFault,
|
||||
removeEquipmentFault,
|
||||
removeBatchEquipmentFault
|
||||
} from '@/api/apps/equipment/fault';
|
||||
import type {
|
||||
EquipmentFault,
|
||||
EquipmentFaultParam
|
||||
} from '@/api/apps/equipment/fault/model';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode',
|
||||
width: 160,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '故障原因',
|
||||
dataIndex: 'faultType',
|
||||
key: 'faultType',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
width: 380,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '处理状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '处理时间',
|
||||
dataIndex: 'handleTime',
|
||||
key: 'handleTime',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<EquipmentFault[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<EquipmentFault | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageEquipmentFault({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentFaultParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: EquipmentFault) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: EquipmentFault) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: EquipmentFault) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeEquipmentFault(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipmentFault(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentFaultIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
39
src/views/yunxinwei/goods/components/category-select.vue
Normal file
39
src/views/yunxinwei/goods/components/category-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 目录选择下拉框 -->
|
||||
<template>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:placeholder="placeholder"
|
||||
:value="value || undefined"
|
||||
:tree-data="data"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Equipment } from '@/api/apps/equipment/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value?: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据(v-modal)
|
||||
value?: number;
|
||||
// 提示信息
|
||||
placeholder?: string;
|
||||
// 文章分类
|
||||
data: Equipment[];
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择上级分类'
|
||||
}
|
||||
);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value?: number) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
714
src/views/yunxinwei/goods/components/equipment-goods-edit.vue
Normal file
714
src/views/yunxinwei/goods/components/equipment-goods-edit.vue
Normal file
@@ -0,0 +1,714 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="880"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑商品' : '添加商品'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="商品下单方式" name="equipmentCategory">
|
||||
<DictSelect
|
||||
dict-code="equipmentCategory"
|
||||
:disabled="isUpdate"
|
||||
placeholder="请选择商品下单方式"
|
||||
v-model:value="form.equipmentCategory"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属商户" name="merchantCode">
|
||||
<MerchantSelect
|
||||
dict-code="merchantCode"
|
||||
placeholder="请选择所属商户"
|
||||
v-model:value="form.merchantCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- 销售 -->
|
||||
<template v-if="form.equipmentCategory === '10'">
|
||||
<a-form-item label="销售价格" name="batteryPrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryPrice"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<!-- 分期 -->
|
||||
<template v-if="form.equipmentCategory === '20'">
|
||||
<a-form-item label="销售价格" name="batteryPrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryPrice"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="首付款" name="downPayment">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.downPayment"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="分期期数" name="periods">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
v-model:value="form.periods"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="每期还款" name="repayment">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.repayment"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="手续费" name="serviceCharges">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.serviceCharges"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<!-- 以租代购 -->
|
||||
<template v-if="form.equipmentCategory === '30'">
|
||||
<a-form-item label="商品总价" name="batteryPrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryPrice"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="分期方式" name="periodsType">
|
||||
<a-radio-group v-model:value="form.periodsType">
|
||||
<a-radio :value="10">按周</a-radio>
|
||||
<a-radio :value="20">按月</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="分期期数" name="periods">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
v-model:value="form.periods"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备租金" name="batteryRent">
|
||||
<a-input-number
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryRent"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备押金" name="batteryDeposit">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryDeposit"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备保险" name="batteryInsurance">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryInsurance"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<!-- 租赁 -->
|
||||
<template v-if="form.equipmentCategory === '40'">
|
||||
<a-form-item label="设备租金" name="batteryRent">
|
||||
<a-input-number
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryRent"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备押金" name="batteryDeposit">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryDeposit"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备保险" name="batteryInsurance">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.batteryInsurance"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="设备名称" name="goodsName">
|
||||
<DictSelect
|
||||
dict-code="equipmentName"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.goodsName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="电池型号" name="batteryModel">
|
||||
<DictSelect
|
||||
dict-code="equipmentModel"
|
||||
placeholder="请选择电池型号"
|
||||
v-model:value="form.batteryModel"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品库存" name="stockTotal">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
v-model:value="form.stockTotal"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品卖点" name="sellingPoint">
|
||||
<a-input v-model:value="form.sellingPoint" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item label="设备图片" name="images">
|
||||
<ele-image-upload
|
||||
v-model:value="images"
|
||||
:limit="1"
|
||||
:drag="true"
|
||||
:upload-handler="uploadHandler"
|
||||
@upload="onUpload"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<!-- <a-tabs v-model:activeKey="activeKey" type="card">-->
|
||||
<!-- <a-tab-pane key="1" tab="基本信息" />-->
|
||||
<!-- <a-tab-pane key="2" tab="设备详情">-->
|
||||
<!-- <a-form-->
|
||||
<!-- ref="formRef"-->
|
||||
<!-- :label-col="{ md: { span: 8 }, sm: { span: 24 } }"-->
|
||||
<!-- :wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"-->
|
||||
<!-- layout="vertical"-->
|
||||
<!-- :model="form"-->
|
||||
<!-- :rules="rules"-->
|
||||
<!-- >-->
|
||||
<!-- <a-form-item label="" name="content">-->
|
||||
<!-- <!– 编辑器 –>-->
|
||||
<!-- <tinymce-editor-->
|
||||
<!-- v-model:value="content"-->
|
||||
<!-- :disabled="disabled"-->
|
||||
<!-- :init="config"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-form>-->
|
||||
<!-- </a-tab-pane>-->
|
||||
<!-- </a-tabs>-->
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { EquipmentGoods } from '@/api/apps/equipment/goods/model';
|
||||
import {
|
||||
addEquipmentGoods,
|
||||
updateEquipmentGoods
|
||||
} from '@/api/apps/equipment/goods';
|
||||
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
// import { Category } from '@/api/goods/category/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import MerchantSelect from '@/components/MerchantSelect/index.vue';
|
||||
// import { createCode } from '@/utils/common';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: EquipmentGoods | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<EquipmentGoods>({
|
||||
goodsId: 1,
|
||||
goodsName: '',
|
||||
equipmentCategory: undefined,
|
||||
image: undefined,
|
||||
qrcode: '',
|
||||
batteryModel: undefined,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
stockTotal: 0,
|
||||
content: '',
|
||||
sellingPoint: undefined,
|
||||
merchantCode: undefined,
|
||||
batteryRent: 0,
|
||||
batteryDeposit: 0,
|
||||
batteryInsurance: 0,
|
||||
batteryPrice: 0,
|
||||
userId: 0,
|
||||
downPayment: 0,
|
||||
periods: 0,
|
||||
repayment: 0,
|
||||
serviceCharges: 0,
|
||||
periodsType: 0,
|
||||
tenantId: Number(localStorage.getItem('tenantId'))
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
console.log(file);
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
form.image = data.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
// merchantCode: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请选择商户',
|
||||
// type: 'string',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
goodsName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryModel: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择电池型号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryPrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入销售价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryRent: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入租金金额',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCategory: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择设备分类',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写设备编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
isCtive: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择是否激活',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择配送方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentPriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备价格',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
stockTotal: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备库存',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
specType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择规格类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择运费模板',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deductStockType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置库存计算方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
purchaseLimit: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置是否限购',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
customerId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择客户'
|
||||
}
|
||||
],
|
||||
linePriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备划线价',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入文章内容',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == '') {
|
||||
return Promise.reject('请输入文字内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
brand: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选项设备厂商',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
|
||||
const config = ref({
|
||||
height: 500,
|
||||
// 自定义文件上传(这里使用把选择的文件转成 blob 演示)
|
||||
file_picker_callback: (callback: any, _value: any, meta: any) => {
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('type', 'file');
|
||||
// 设定文件可选类型
|
||||
if (meta.filetype === 'image') {
|
||||
input.setAttribute('accept', 'image/*');
|
||||
} else if (meta.filetype === 'media') {
|
||||
input.setAttribute('accept', 'video/*');
|
||||
}
|
||||
input.onchange = () => {
|
||||
const file = input.files?.[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
if (meta.filetype === 'media') {
|
||||
if (!file.type.startsWith('video/')) {
|
||||
editorRef.value?.alert({ content: '只能选择视频文件' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 20) {
|
||||
editorRef.value?.alert({ content: '大小不能超过 20MB' });
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
if (e.target?.result != null) {
|
||||
const blob = new Blob([e.target.result], { type: file.type });
|
||||
callback(URL.createObjectURL(blob));
|
||||
}
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipmentGoods(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateEquipmentGoods
|
||||
: addEquipmentGoods;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
images.value = [];
|
||||
images.value.push({
|
||||
uid: 1,
|
||||
url: props.data.image,
|
||||
status: 'done'
|
||||
});
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
145
src/views/yunxinwei/goods/components/search.vue
Normal file
145
src/views/yunxinwei/goods/components/search.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
:disabled="props.selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-radio-group v-model:value="listType" @change="handleTabs">-->
|
||||
<!-- <a-radio-button value="all">全部</a-radio-button>-->
|
||||
<!-- <a-radio-button value="onSale">出售中</a-radio-button>-->
|
||||
<!-- <a-radio-button value="offSale">已下架</a-radio-button>-->
|
||||
<!-- <a-radio-button value="soldOut">已售罄</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="equipmentName">设备名称</a-select-option>
|
||||
<a-select-option value="merchantCode">商户编号</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
// const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
where.equipmentName = undefined;
|
||||
where.equipmentCode = undefined;
|
||||
where.merchantCode = undefined;
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// listType.value = e.target.value;
|
||||
// if (listType.value == 'all') {
|
||||
// resetFields();
|
||||
// }
|
||||
// if (listType.value == 'onSale') {
|
||||
// where.status = 0;
|
||||
// }
|
||||
// if (listType.value == 'offSale') {
|
||||
// where.status = 1;
|
||||
// }
|
||||
// if (listType.value == 'soldOut') {
|
||||
// where.stockTotal = 0;
|
||||
// }
|
||||
// emit('search', where);
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
462
src/views/yunxinwei/goods/index.vue
Normal file
462
src/views/yunxinwei/goods/index.vue
Normal file
@@ -0,0 +1,462 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="商品管理">
|
||||
<div class="ele-text-secondary"> 商品管理,云芯威电池管理定制模块。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="goodsId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<span>{{ record.equipmentCode }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<a-image :src="record.image" :preview="false" :width="50" />
|
||||
{{ record.goodsName }}
|
||||
</template>
|
||||
<template v-if="column.key === 'merchantName'">
|
||||
<div style="display: flex; flex-direction: column">
|
||||
<span>{{ record.merchantName }}</span>
|
||||
<span class="ele-text-placeholder">
|
||||
{{ record.merchantCode }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'qrcode'">
|
||||
<a-image :src="record.qrcode" :width="50" />
|
||||
</template>
|
||||
<!-- <template v-if="column.key === 'batteryPrice'">-->
|
||||
<!-- <strong class="ele-text-danger">-->
|
||||
<!-- ¥{{ record.batteryPrice }}-->
|
||||
<!-- </strong>-->
|
||||
<!-- </template>-->
|
||||
<template v-if="column.key === 'batteryDeposit'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryDeposit }}
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryInsurance'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryInsurance }}
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'isOnline'">
|
||||
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">异常</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentCategory'">
|
||||
<a-tag
|
||||
v-if="Number(record.equipmentCategory) === 10"
|
||||
color="success"
|
||||
>销售</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.equipmentCategory) === 20" color="red"
|
||||
>分期</a-tag
|
||||
>
|
||||
<a-tag
|
||||
v-if="Number(record.equipmentCategory) === 30"
|
||||
color="orange"
|
||||
>以租代购</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.equipmentCategory) === 40" color="blue"
|
||||
>租赁</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'sellingPoint'">
|
||||
<a-tooltip :title="record.sellingPoint" placement="topLeft">
|
||||
{{ record.sellingPoint }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'userId'">
|
||||
<a-tag v-if="record.userId > 0" color="green">已绑定</a-tag>
|
||||
<a-tag v-else color="orange">未绑定</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryPrice'">
|
||||
<div class="ele-text-placeholder">
|
||||
价格:<span class="ele-text-heading">¥{{ record.batteryPrice }}</span>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
租金:<span class="ele-text-heading">¥{{ record.batteryRent }}</span>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
押金:<span class="ele-text-heading">¥{{ record.batteryDeposit }}</span>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
保险:<span class="ele-text-heading">¥{{ record.batteryInsurance }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'more'">
|
||||
<div v-if="record.periodsType > 0">
|
||||
<span class="ele-text-placeholder">分期方式:</span>
|
||||
{{ record.periodsType === 0 ? '周' : '月' }}
|
||||
</div>
|
||||
<div v-if="record.periods > 0">
|
||||
<span class="ele-text-placeholder">分期期数:</span>
|
||||
{{ record.periods }}
|
||||
</div>
|
||||
<div v-if="record.downPayment">
|
||||
<span class="ele-text-placeholder">首付款:</span>
|
||||
{{ record.downPayment }}
|
||||
</div>
|
||||
<div v-if="record.repayment > 0">
|
||||
<span class="ele-text-placeholder">每期还款:</span>
|
||||
{{ record.repayment }}
|
||||
</div>
|
||||
<div v-if="record.serviceCharges > 0">
|
||||
<span class="ele-text-placeholder">手续费:</span>
|
||||
{{ record.serviceCharges }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-button
|
||||
type="link"
|
||||
@click="onStatus(record.goodsId, 1)"
|
||||
v-if="record.status === 0"
|
||||
class="ele-text-success"
|
||||
>已上架</a-button
|
||||
>
|
||||
<a-button type="link" @click="onStatus(record.goodsId, 0)" v-else
|
||||
>已下架</a-button
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openEdit(record)">修改</a-button>
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要删除此记录吗?"-->
|
||||
<!-- @confirm="remove(record)"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="ele-text-danger">删除</a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<equipment-goods-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import EquipmentGoodsEdit from './components/equipment-goods-edit.vue';
|
||||
import {
|
||||
pageEquipmentGoods,
|
||||
removeBatchEquipmentGoods,
|
||||
updateEquipmentGoods
|
||||
} from '@/api/apps/equipment/goods';
|
||||
import type {
|
||||
EquipmentGoods,
|
||||
EquipmentGoodsParam
|
||||
} from '@/api/apps/equipment/goods/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// key: 'index',
|
||||
// width: 48,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true,
|
||||
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
// },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 120,
|
||||
fixed: 'left',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '商品ID',
|
||||
dataIndex: 'goodsId',
|
||||
key: 'goodsId',
|
||||
width: 70,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '下单方式',
|
||||
dataIndex: 'equipmentCategory',
|
||||
width: 100,
|
||||
key: 'equipmentCategory'
|
||||
},
|
||||
{
|
||||
title: '商品名称',
|
||||
dataIndex: 'goodsName',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
key: 'goodsName',
|
||||
fixed: 'left'
|
||||
},
|
||||
// {
|
||||
// title: '商品图片',
|
||||
// dataIndex: 'image',
|
||||
// key: 'image'
|
||||
// },
|
||||
// {
|
||||
// title: '二维码',
|
||||
// dataIndex: 'qrcode',
|
||||
// key: 'qrcode'
|
||||
// },
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName'
|
||||
},
|
||||
{
|
||||
title: '电池型号',
|
||||
dataIndex: 'batteryModel',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '电池价格',
|
||||
dataIndex: 'batteryPrice',
|
||||
sorter: true,
|
||||
key: 'batteryPrice'
|
||||
},
|
||||
// {
|
||||
// title: '电池租金',
|
||||
// dataIndex: 'batteryRent',
|
||||
// key: 'batteryRent'
|
||||
// },
|
||||
// {
|
||||
// title: '电池押金',
|
||||
// dataIndex: 'batteryDeposit',
|
||||
// sorter: true,
|
||||
// key: 'batteryDeposit'
|
||||
// },
|
||||
// {
|
||||
// title: '电池保险',
|
||||
// dataIndex: 'batteryInsurance',
|
||||
// sorter: true,
|
||||
// key: 'batteryInsurance'
|
||||
// },
|
||||
{
|
||||
title: '分期方案',
|
||||
dataIndex: 'more',
|
||||
key: 'more'
|
||||
},
|
||||
{
|
||||
title: '商品卖点',
|
||||
dataIndex: 'sellingPoint',
|
||||
key: 'sellingPoint',
|
||||
ellipsis: true,
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortNumber',
|
||||
align: 'center',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
key: 'status',
|
||||
fixed: 'right',
|
||||
customRender: ({ text }) => ['上架', '下架'][text]
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<EquipmentGoods[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<EquipmentGoods | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
// const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// if (filters) {
|
||||
// where.brand = filters.brand;
|
||||
// }
|
||||
return pageEquipmentGoods({ ...where, ...orders, ...filters, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentGoodsParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: EquipmentGoods) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onStatus = (goodsId, status) => {
|
||||
updateEquipmentGoods({ goodsId, status }).then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
// const openInfo = (row?: EquipmentGoods) => {
|
||||
// current.value = row ?? null;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
// const remove = (row: EquipmentGoods) => {
|
||||
// const hide = message.loading('请求中..', 0);
|
||||
// removeEquipmentGoods(row.equipmentId)
|
||||
// .then((msg) => {
|
||||
// hide();
|
||||
// message.success(msg);
|
||||
// reload();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// hide();
|
||||
// message.error(e.message);
|
||||
// });
|
||||
// };
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipmentGoods(selection.value.map((d) => d.goodsId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: EquipmentGoods) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentGoodsIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
39
src/views/yunxinwei/index/components/category-select.vue
Normal file
39
src/views/yunxinwei/index/components/category-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 目录选择下拉框 -->
|
||||
<template>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:placeholder="placeholder"
|
||||
:value="value || undefined"
|
||||
:tree-data="data"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Equipment } from '@/api/apps/equipment/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value?: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据(v-modal)
|
||||
value?: number;
|
||||
// 提示信息
|
||||
placeholder?: string;
|
||||
// 文章分类
|
||||
data: Equipment[];
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择上级分类'
|
||||
}
|
||||
);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value?: number) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
669
src/views/yunxinwei/index/components/equipment-edit.vue
Normal file
669
src/views/yunxinwei/index/components/equipment-edit.vue
Normal file
@@ -0,0 +1,669 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="880"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑设备' : '添加设备'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="所属商户" name="merchantCode">
|
||||
<MerchantSelect
|
||||
dict-code="merchantCode"
|
||||
placeholder="请选择所属商户"
|
||||
v-model:value="form.merchantCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- 1锂电池租赁 3电动车租赁 -->
|
||||
<a-form-item label="设备名称" name="equipmentName">
|
||||
<DictSelect
|
||||
dict-code="equipmentName"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.equipmentName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="电池型号" name="batteryModel">
|
||||
<DictSelect
|
||||
dict-code="equipmentModel"
|
||||
placeholder="请选择电池型号"
|
||||
v-model:value="form.batteryModel"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="工作状态" name="workingStatus">
|
||||
<DictSelect
|
||||
dict-code="workingStatus"
|
||||
v-model:value="form.workingStatus"
|
||||
placeholder="选择工作状态"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="电池状态" name="batteryStatus">
|
||||
<DictSelect
|
||||
dict-code="batteryStatus"
|
||||
v-model:value="form.batteryStatus"
|
||||
placeholder="选择电池状态"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否在线" name="isOnline">
|
||||
<DictSelect
|
||||
dict-code="isOnline"
|
||||
v-model:value="form.isOnline"
|
||||
placeholder="是否在线"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="BMS板供应商" name="bmsBrand">
|
||||
<DictSelect
|
||||
dict-code="bmsBrand"
|
||||
v-model:value="form.bmsBrand"
|
||||
placeholder="选择供应商"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="ICCID" name="iccid">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入剩余容量"
|
||||
v-model:value="form.iccid"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="电池出厂时间" name="batteryDeliveryTime">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
placeholder="请选择时间"
|
||||
v-model:value="batteryDeliveryTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="设备编码" name="equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备编码"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="bms" name="bms">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备BMS"
|
||||
v-model:value="form.bms"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否激活" name="isCtive">
|
||||
<DictSelect
|
||||
dict-code="ctiveStatus"
|
||||
v-model:value="form.isCtive"
|
||||
placeholder="是否激活"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="租赁状态" name="leaseStatus">
|
||||
<DictSelect
|
||||
dict-code="leaseStatus"
|
||||
v-model:value="form.leaseStatus"
|
||||
placeholder="是否激活"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="电池电量" name="batteryPower">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入电池电量"
|
||||
v-model:value="form.batteryPower"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="总电压" name="totalVoltage">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入总电压"
|
||||
v-model:value="form.totalVoltage"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="剩余容量" name="surplusCapacity">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入剩余容量"
|
||||
v-model:value="form.surplusCapacity"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备激活时间" name="ctiveTime">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
placeholder="请选择时间"
|
||||
v-model:value="ctiveTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备开关" name="status">
|
||||
<a-switch :checked="form.status === 0" @change="editStatus" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<!-- <a-form-item label="设备图片" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="14"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<!-- <a-tabs v-model:activeKey="activeKey" type="card">-->
|
||||
<!-- <a-tab-pane key="1" tab="基本信息" />-->
|
||||
<!-- <a-tab-pane key="2" tab="设备详情">-->
|
||||
<!-- <a-form-->
|
||||
<!-- ref="formRef"-->
|
||||
<!-- :label-col="{ md: { span: 8 }, sm: { span: 24 } }"-->
|
||||
<!-- :wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"-->
|
||||
<!-- layout="vertical"-->
|
||||
<!-- :model="form"-->
|
||||
<!-- :rules="rules"-->
|
||||
<!-- >-->
|
||||
<!-- <a-form-item label="" name="content">-->
|
||||
<!-- <!– 编辑器 –>-->
|
||||
<!-- <tinymce-editor-->
|
||||
<!-- v-model:value="content"-->
|
||||
<!-- :disabled="disabled"-->
|
||||
<!-- :init="config"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-form>-->
|
||||
<!-- </a-tab-pane>-->
|
||||
<!-- </a-tabs>-->
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { Equipment } from '@/api/apps/equipment/model';
|
||||
import { addEquipment, updateEquipment } from '@/api/apps/equipment';
|
||||
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import MerchantSelect from '@/components/MerchantSelect/index.vue';
|
||||
import { createCode } from '@/utils/common';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Equipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Equipment>({
|
||||
equipmentType: 1,
|
||||
equipmentName: undefined,
|
||||
equipmentCode: `E${createCode()}`,
|
||||
batteryModel: undefined,
|
||||
equipmentCategory: undefined,
|
||||
bms: undefined,
|
||||
isCtive: undefined,
|
||||
workingStatus: undefined,
|
||||
leaseStatus: undefined,
|
||||
batteryStatus: undefined,
|
||||
batteryPower: undefined,
|
||||
isOnline: undefined,
|
||||
totalVoltage: undefined,
|
||||
bmsBrand: undefined,
|
||||
surplusCapacity: undefined,
|
||||
iccid: undefined,
|
||||
ctiveTime: undefined,
|
||||
batteryDeliveryTime: undefined,
|
||||
image: '',
|
||||
files: '',
|
||||
createTime: '',
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
equipmentId: 0,
|
||||
content: '',
|
||||
merchantCode: undefined,
|
||||
batteryRent: 300,
|
||||
batteryDeposit: 300,
|
||||
batteryInsurance: 0,
|
||||
batteryPrice: 0,
|
||||
tenantId: Number(localStorage.getItem('tenantId'))
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
merchantCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择商户',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryModel: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择电池型号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryPrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入销售价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
batteryRent: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入租金金额',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCategory: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择设备分类',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写设备编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
isCtive: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择是否激活',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择配送方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentPriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备价格',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
stockTotal: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备库存',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
specType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择规格类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择运费模板',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deductStockType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置库存计算方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
purchaseLimit: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置是否限购',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
customerId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择客户'
|
||||
}
|
||||
],
|
||||
linePriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入设备划线价',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入文章内容',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == '') {
|
||||
return Promise.reject('请输入文字内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
brand: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选项设备厂商',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
|
||||
const config = ref({
|
||||
height: 500,
|
||||
// 自定义文件上传(这里使用把选择的文件转成 blob 演示)
|
||||
file_picker_callback: (callback: any, _value: any, meta: any) => {
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('type', 'file');
|
||||
// 设定文件可选类型
|
||||
if (meta.filetype === 'image') {
|
||||
input.setAttribute('accept', 'image/*');
|
||||
} else if (meta.filetype === 'media') {
|
||||
input.setAttribute('accept', 'video/*');
|
||||
}
|
||||
input.onchange = () => {
|
||||
const file = input.files?.[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
if (meta.filetype === 'media') {
|
||||
if (!file.type.startsWith('video/')) {
|
||||
editorRef.value?.alert({ content: '只能选择视频文件' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 20) {
|
||||
editorRef.value?.alert({ content: '大小不能超过 20MB' });
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
if (e.target?.result != null) {
|
||||
const blob = new Blob([e.target.result], { type: file.type });
|
||||
callback(URL.createObjectURL(blob));
|
||||
}
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value ? updateEquipment : addEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
// images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
145
src/views/yunxinwei/index/components/search.vue
Normal file
145
src/views/yunxinwei/index/components/search.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
:disabled="props.selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-radio-group v-model:value="listType" @change="handleTabs">-->
|
||||
<!-- <a-radio-button value="all">全部</a-radio-button>-->
|
||||
<!-- <a-radio-button value="onSale">出售中</a-radio-button>-->
|
||||
<!-- <a-radio-button value="offSale">已下架</a-radio-button>-->
|
||||
<!-- <a-radio-button value="soldOut">已售罄</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="equipmentName">设备名称</a-select-option>
|
||||
<a-select-option value="merchantCode">商户编号</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
// const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
where.equipmentName = undefined;
|
||||
where.equipmentCode = undefined;
|
||||
where.merchantCode = undefined;
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// listType.value = e.target.value;
|
||||
// if (listType.value == 'all') {
|
||||
// resetFields();
|
||||
// }
|
||||
// if (listType.value == 'onSale') {
|
||||
// where.status = 0;
|
||||
// }
|
||||
// if (listType.value == 'offSale') {
|
||||
// where.status = 1;
|
||||
// }
|
||||
// if (listType.value == 'soldOut') {
|
||||
// where.stockTotal = 0;
|
||||
// }
|
||||
// emit('search', where);
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
377
src/views/yunxinwei/index/index.vue
Normal file
377
src/views/yunxinwei/index/index.vue
Normal file
@@ -0,0 +1,377 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="设备管理">
|
||||
<div class="ele-text-secondary"> 设备管理,云芯威电池管理定制模块。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="equipmentId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 3000 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="40" />
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<span>{{ record.equipmentCode }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentName'">
|
||||
{{ record.equipmentName }}
|
||||
</template>
|
||||
<template v-if="column.key === 'merchantName'">
|
||||
<div style="display: flex; flex-direction: column">
|
||||
<span>{{ record.merchantName }}</span>
|
||||
<span class="ele-text-placeholder">
|
||||
商户编号:{{ record.merchantCode }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'user'">
|
||||
<User v-if="record.user" :record="record.user" />
|
||||
</template>
|
||||
<template v-if="column.key === 'qrcode'">
|
||||
<a-image :src="record.qrcode" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryPrice'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryPrice }}
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryRent'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryRent }}/月
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryDeposit'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryDeposit }}
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryInsurance'">
|
||||
<strong class="ele-text-danger">
|
||||
¥{{ record.batteryInsurance }}
|
||||
</strong>
|
||||
</template>
|
||||
<template v-if="column.key === 'isOnline'">
|
||||
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">异常</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'userId'">
|
||||
<a-tag v-if="record.userId === 0" color="orange">未绑定</a-tag>
|
||||
<a-tag v-else color="green">已绑定</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openEdit(record)">修改</a-button>
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要删除此记录吗?"-->
|
||||
<!-- @confirm="remove(record)"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="ele-text-danger">删除</a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<equipment-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import EquipmentEdit from './components/equipment-edit.vue';
|
||||
import { pageEquipment, removeBatchEquipment } from '@/api/apps/equipment';
|
||||
import type { Equipment, EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 90,
|
||||
fixed: 'left',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '二维码',
|
||||
dataIndex: 'qrcode',
|
||||
key: 'qrcode',
|
||||
fixed: 'left',
|
||||
align: 'center',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName',
|
||||
sorter: true,
|
||||
width: 220,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '用户信息',
|
||||
dataIndex: 'user',
|
||||
key: 'user'
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
dataIndex: 'equipmentName',
|
||||
key: 'equipmentName'
|
||||
},
|
||||
{
|
||||
title: '激活状态',
|
||||
dataIndex: 'isCtive',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '在线状态',
|
||||
dataIndex: 'isOnline',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '电池型号',
|
||||
dataIndex: 'batteryModel',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'BMS',
|
||||
dataIndex: 'bms',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '工作状态',
|
||||
dataIndex: 'workingStatus',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '租赁状态',
|
||||
dataIndex: 'leaseStatus',
|
||||
sorter: true,
|
||||
key: 'leaseStatus'
|
||||
},
|
||||
{
|
||||
title: '电池状态',
|
||||
dataIndex: 'batteryStatus',
|
||||
sorter: true,
|
||||
key: 'batteryStatus',
|
||||
showSorterTooltip: false,
|
||||
customRender: ({ text }) => ['上架', '下架'][text]
|
||||
},
|
||||
{
|
||||
title: '电池电量',
|
||||
dataIndex: 'batteryPower',
|
||||
sorter: true,
|
||||
key: 'batteryPower'
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortNumber',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '绑定状态',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
fixed: 'right',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
sorter: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Equipment[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Equipment | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
// const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// if (filters) {
|
||||
// where.brand = filters.brand;
|
||||
// }
|
||||
return pageEquipment({ ...where, ...orders, ...filters, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Equipment) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
// const openInfo = (row?: Equipment) => {
|
||||
// current.value = row ?? null;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
// const remove = (row: Equipment) => {
|
||||
// const hide = message.loading('请求中..', 0);
|
||||
// removeEquipment(row.equipmentId)
|
||||
// .then((msg) => {
|
||||
// hide();
|
||||
// message.success(msg);
|
||||
// reload();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// hide();
|
||||
// message.error(e.message);
|
||||
// });
|
||||
// };
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipment(selection.value.map((d) => d.equipmentId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
186
src/views/yunxinwei/order/components/delivery.vue
Normal file
186
src/views/yunxinwei/order/components/delivery.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="500"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '发货' : '发货'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-space>
|
||||
<a-form>
|
||||
<a-form-item label="设备编码" v-bind="validateInfos.equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
placeholder="请输入设备编码"
|
||||
v-model:value="form.equipmentCode"
|
||||
@blur="
|
||||
validate('equipmentCode', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-row :gutter="16">-->
|
||||
<!-- <a-col :md="12" :sm="24" :xs="24">-->
|
||||
<!-- <a-form-item label="选择设备" v-bind="validateInfos.customerName">-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :maxlength="30"-->
|
||||
<!-- placeholder="请选择设备"-->
|
||||
<!-- v-model:value="form.customerName"-->
|
||||
<!-- @blur="-->
|
||||
<!-- validate('customerName', { trigger: 'blur' }).catch(() => {})-->
|
||||
<!-- "-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- <a-col :md="12" :sm="24" :xs="24">-->
|
||||
<!-- <a-form-item label="手机号码" v-bind="validateInfos.customerMobile">-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :maxlength="20"-->
|
||||
<!-- placeholder="请填写联系人手机号码"-->
|
||||
<!-- v-model:value="form.customerMobile"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- </a-row>-->
|
||||
</a-form>
|
||||
</a-space>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import TypeSelect from './customer-edit/type-select.vue';
|
||||
import ProgressSelect from './customer-edit/progress-select.vue';
|
||||
import SourceSelect from './customer-edit/source-select.vue';
|
||||
import { bindEquipment } from '@/api/apps/equipment';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { createCode } from '@/utils/common';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import type { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { Equipment } from "@/api/apps/equipment/model";
|
||||
import { Order } from "@/api/order/model";
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Equipment>({
|
||||
equipmentCode: '',
|
||||
orderId: undefined
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入设备编码',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
const data = {
|
||||
...form,
|
||||
orderId: props.data?.orderId,
|
||||
userId: props.data?.userId
|
||||
};
|
||||
// 转字符串
|
||||
bindEquipment(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.customerAvatar = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.customerAvatar){
|
||||
images.value.push({ uid:1, url: FILE_SERVER + props.data.customerAvatar, status: '' });
|
||||
}
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.customerCode = createCode();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
118
src/views/yunxinwei/order/components/field.vue
Normal file
118
src/views/yunxinwei/order/components/field.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="500px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改价格`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form layout="horizontal">
|
||||
<a-form-item>
|
||||
<a-input-number :min="0" style="width: 200px" v-model:value="content" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { createOrderNo } from "@/utils/common";
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
orderId?: number | 0;
|
||||
content?: number | 0;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref<number>(0);
|
||||
const placeholder = ref('请输入订单金额');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: '',
|
||||
payPrice: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'payPrice') {
|
||||
form.payPrice = Number(content.value);
|
||||
form.totalPrice = Number(content.value);
|
||||
form.orderNo = createOrderNo();
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.orderId) {
|
||||
loading.value = false;
|
||||
content.value = props.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
|
||||
if (props.field == 'tenantCode') {
|
||||
placeholder.value = '请输入要绑定的主体编号';
|
||||
content.value = undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
139
src/views/yunxinwei/order/components/markdown.vue
Normal file
139
src/views/yunxinwei/order/components/markdown.vue
Normal file
@@ -0,0 +1,139 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="600px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改内容`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- 编辑器 -->
|
||||
<byte-md-editor
|
||||
v-model:value="content"
|
||||
:locale="zh_Hans"
|
||||
:plugins="plugins"
|
||||
uploadImages
|
||||
height="300px"
|
||||
:editorConfig="{ lineNumbers: true }"
|
||||
/>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
import 'bytemd/dist/index.min.css';
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
// import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
import ByteMdEditor from '@/components/ByteMdEditor/index.vue';
|
||||
import highlight from '@bytemd/plugin-highlight';
|
||||
// 中文语言文件
|
||||
import zh_Hans from 'bytemd/locales/zh_Hans.json';
|
||||
// // 链接、删除线、复选框、表格等的插件
|
||||
import gfm from '@bytemd/plugin-gfm';
|
||||
// // 插件的中文语言文件
|
||||
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
|
||||
// // 预览界面的样式,这里用的 github 的 markdown 主题
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
content?: string;
|
||||
orderId?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 插件
|
||||
const plugins = ref([
|
||||
gfm({
|
||||
locale: zh_HansGfm
|
||||
}),
|
||||
highlight()
|
||||
]);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref('');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: ''
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'content') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
if (props.field === 'comments') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
content.value = String(props.content);
|
||||
console.log(visible);
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
content.value = String(props.content);
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
289
src/views/yunxinwei/order/components/order-edit.vue
Normal file
289
src/views/yunxinwei/order/components/order-edit.vue
Normal file
@@ -0,0 +1,289 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="680"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑订单' : '添加订单'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-space>
|
||||
<a-form
|
||||
:label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="订单名称" v-bind="validateInfos.customerName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
placeholder="请输入订单名称"
|
||||
v-model:value="form.customerName"
|
||||
@blur="
|
||||
validate('customerName', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单标识" v-bind="validateInfos.customerCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入用户账号"
|
||||
v-model:value="form.customerCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="跟进状态" v-bind="validateInfos.progress">
|
||||
<progress-select
|
||||
v-model:value="form.progress"
|
||||
@blur="
|
||||
validate('progress', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单类型" v-bind="validateInfos.customerType">
|
||||
<type-select
|
||||
v-model:value="form.customerType"
|
||||
@blur="
|
||||
validate('customerType', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单来源" v-bind="validateInfos.customerSource">
|
||||
<source-select
|
||||
v-model:value="form.customerSource"
|
||||
@blur="
|
||||
validate('customerSource', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="头像" v-bind="validateInfos.customerAvatar">
|
||||
<ele-image-upload
|
||||
v-model:value="images"
|
||||
:item-style="{ width: '90px', height: '90px' }"
|
||||
:limit="1"
|
||||
@upload="onUpload"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="联系人" v-bind="validateInfos.customerContacts">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人"
|
||||
v-model:value="form.customerContacts"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="手机号码" v-bind="validateInfos.customerMobile">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人手机号码"
|
||||
v-model:value="form.customerMobile"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="联系地址"
|
||||
v-bind="validateInfos.customerAddress"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请填写联系地址"
|
||||
v-model:value="form.customerAddress"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="公司座机" v-bind="validateInfos.customerPhone">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写公司座机电话"
|
||||
v-model:value="form.customerPhone"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" v-bind="validateInfos.sortNumber">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="排序"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" v-bind="validateInfos.comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-space>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import TypeSelect from './customer-edit/type-select.vue';
|
||||
import ProgressSelect from './customer-edit/progress-select.vue';
|
||||
import SourceSelect from './customer-edit/source-select.vue';
|
||||
import { addCustomer, updateCustomer } from '@/api/oa/customer';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { createCode } from '@/utils/common';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import type { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Customer | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Customer>({
|
||||
customerCode: '',
|
||||
customerName: '',
|
||||
customerType: undefined,
|
||||
progress: undefined,
|
||||
customerMobile: '',
|
||||
customerAvatar: '',
|
||||
customerPhone: '',
|
||||
customerContacts: '',
|
||||
customerAddress: '',
|
||||
comments: '',
|
||||
status: '0',
|
||||
sortNumber: 100,
|
||||
customerId: 0,
|
||||
userId: '',
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
customerName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入订单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
customerCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入合法的IP地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
progress: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择跟进状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
form.customerName = form.customerName?.replace(/\s*/g, '');
|
||||
if(isUpdate.value == false) {
|
||||
form.userId = loginUser.value.userId;
|
||||
}
|
||||
const data = {
|
||||
...form
|
||||
};
|
||||
// 转字符串
|
||||
const saveOrUpdate = isUpdate.value ? updateCustomer : addCustomer;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.customerAvatar = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.customerAvatar){
|
||||
images.value.push({ uid:1, url: FILE_SERVER + props.data.customerAvatar, status: '' });
|
||||
}
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.customerCode = createCode();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
715
src/views/yunxinwei/order/components/order-info.vue
Normal file
715
src/views/yunxinwei/order/components/order-info.vue
Normal file
@@ -0,0 +1,715 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="`80%`"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑订单' : '订单详情'"
|
||||
:body-style="{ paddingBottom: '8px', background: '#f3f3f3' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
:footer="null"
|
||||
@ok="save"
|
||||
>
|
||||
<a-card class="order-card" :bordered="false">
|
||||
<a-steps
|
||||
:current="active"
|
||||
direction="horizontal"
|
||||
:responsive="styleResponsive"
|
||||
>
|
||||
<template v-for="(item, index) in steps" :key="index">
|
||||
<a-step
|
||||
:title="item.title"
|
||||
:description="timeAgo(item.description)"
|
||||
/>
|
||||
</template>
|
||||
</a-steps>
|
||||
</a-card>
|
||||
<a-card title="订单操作" class="order-card">
|
||||
<a-space>
|
||||
<a-button>发货</a-button>
|
||||
<a-button>商家备注</a-button>
|
||||
<a-button>打印小票</a-button>
|
||||
</a-space>
|
||||
<a-row :gutter="16" style="margin-top: 34px">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单编号" name="orderNo">
|
||||
<span>{{ data.orderNo }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="实付款金额" name="payPrice">
|
||||
<span class="ele-text-warning">¥{{ formatNumber(data.payPrice) }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="支付方式" name="payMethod">
|
||||
<Tag dict-code="payMethod" v-model:value="data.payMethod" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="配送方式" name="deliveryType">
|
||||
<Tag dict-code="deliveryType" v-model:value="data.deliveryType" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="运费金额" name="deliveryType">
|
||||
<span>¥{{ formatNumber(data.expressPrice) }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单状态" name="orderStatus">
|
||||
<Tag dict-code="orderStatus" v-model:value="data.orderStatus" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家信息" name="deliveryType">
|
||||
<router-link :to="'/system/user/details?id=' + data.userId">
|
||||
<span class="ele-text-primary">{{ data.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="第三方交易号" name="tradeId">
|
||||
<span>{{ data.tradeId }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="设备编号" name="equipmentCode">
|
||||
<span>
|
||||
{{ bindEquipmentCode }}
|
||||
<copy-outlined
|
||||
style="padding-left: 4px"
|
||||
@click="copyText(bindEquipmentCode)"
|
||||
/>
|
||||
</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="下单时间" name="createTime">
|
||||
{{ data.createTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="到期时间" name="expirationTime">
|
||||
{{ data.expirationTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家留言" name="buyerRemark">
|
||||
<span>{{ data.buyerRemark }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单备注" name="comments">
|
||||
<span>{{ data.comments }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card title="订单商品" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="EquipmentOrderGoodsList"
|
||||
:columns="columns"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<a-image
|
||||
v-if="record.image"
|
||||
:src="record.image"
|
||||
:preview="false"
|
||||
:width="50"
|
||||
/>
|
||||
<span>{{ record.goodsName }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'batteryRent'">
|
||||
<div>电池租金:¥{{ record.batteryRent }}</div>
|
||||
<div>电池押金:¥{{ record.batteryDeposit }}</div>
|
||||
<div>电池保险:¥{{ record.batteryInsurance }}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentCategory'">
|
||||
<a-tag
|
||||
v-if="Number(record.equipmentCategory) === 10"
|
||||
color="success"
|
||||
>销售</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.equipmentCategory) === 20" color="red"
|
||||
>分期</a-tag
|
||||
>
|
||||
<a-tag
|
||||
v-if="Number(record.equipmentCategory) === 30"
|
||||
color="orange"
|
||||
>以租代购</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.equipmentCategory) === 40" color="blue"
|
||||
>租赁</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'more'">
|
||||
<div v-if="record.periodsType > 0">
|
||||
<span class="ele-text-placeholder">分期方式:</span>
|
||||
{{ record.periodsType === 0 ? '周' : '月' }}
|
||||
</div>
|
||||
<div v-if="record.periods > 0">
|
||||
<span class="ele-text-placeholder">分期期数:</span>
|
||||
{{ record.periods }}
|
||||
</div>
|
||||
<div v-if="record.downPayment">
|
||||
<span class="ele-text-placeholder">首付款:</span>
|
||||
{{ record.downPayment }}
|
||||
</div>
|
||||
<div v-if="record.repayment > 0">
|
||||
<span class="ele-text-placeholder">每期还款:</span>
|
||||
{{ record.repayment }}
|
||||
</div>
|
||||
<div v-if="record.serviceCharges > 0">
|
||||
<span class="ele-text-placeholder">手续费:</span>
|
||||
{{ record.serviceCharges }}
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
<a-card title="换电记录" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="equipmentRecordList"
|
||||
:columns="columns3"
|
||||
ref="tableRef3"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'batteryModel'">
|
||||
<div>电池租金:¥{{ record.batteryDeposit }}</div>
|
||||
<div>电池押金:¥{{ record.batteryDeposit }}</div>
|
||||
<div>电池保险:¥{{ record.batteryInsurance }}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'expirationDay'">
|
||||
<span class="ele-text-danger">{{ expirationDay(record) }}</span>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
<a-card title="续费订单" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="renewOrderList"
|
||||
:columns="columns2"
|
||||
ref="tableRef2"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'batteryModel'">
|
||||
<div>电池租金:¥{{ record.batteryDeposit }}</div>
|
||||
<div>电池押金:¥{{ record.batteryDeposit }}</div>
|
||||
<div>电池保险:¥{{ record.batteryInsurance }}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'expirationTime'">
|
||||
<div>{{ record.startTime }}</div>
|
||||
<div>{{ record.expirationTime}}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'expirationDay'">
|
||||
<span class="ele-text-danger">{{ expirationDay(record) }}</span>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
<a-card title="订单附件" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<ele-image-upload
|
||||
v-model:value="files"
|
||||
disabled
|
||||
:item-style="{ width: '150px', height: '99px' }"
|
||||
/>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
<a-card title="买家收货地址" class="order-card">
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="收货人姓名" name="orderNo">
|
||||
<router-link :to="'/system/user/details?id=' + data.userId">
|
||||
<span class="ele-text-primary">{{ data.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="联系电话" name="payPrice" />
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="所在地区" name="payMethod" />
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="详细地址" name="payMethod" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { assignObject, EleProTable, timeAgo } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { copyText } from '@/utils/common';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { listEquipmentOrderGoods } from '@/api/apps/equipment/order/goods';
|
||||
import { EquipmentOrderGoods } from '@/api/apps/equipment/order/goods/model';
|
||||
import * as EquipmentApi from '@/api/apps/equipment';
|
||||
import * as EquipmentRecordApi from '@/api/apps/equipment/record';
|
||||
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { listOrder } from '@/api/order';
|
||||
import { CopyOutlined } from '@ant-design/icons-vue';
|
||||
import { EquipmentRecord } from '@/api/apps/equipment/record/model';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
export interface step {
|
||||
title?: String | undefined;
|
||||
subTitle?: String | undefined;
|
||||
description?: String | undefined;
|
||||
}
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const EquipmentOrderGoodsList = ref<EquipmentOrderGoods[]>([]);
|
||||
const renewOrderList = ref<Order[]>([]);
|
||||
const equipmentRecordList = ref<EquipmentRecord[]>([]);
|
||||
const bindEquipmentCode = ref<string>();
|
||||
const files = ref<any[]>();
|
||||
|
||||
// 步骤条
|
||||
const steps = ref<step[]>([
|
||||
{
|
||||
title: '下单',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '付款',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '发货',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '收货',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: undefined
|
||||
}
|
||||
]);
|
||||
const active = ref(2);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 订单信息
|
||||
const order = reactive<Order>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
userId: undefined,
|
||||
orderSourceData: ''
|
||||
});
|
||||
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
|
||||
const { resetFields } = useForm(order);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: '商品ID',
|
||||
// dataIndex: 'goodsId'
|
||||
// },
|
||||
{
|
||||
title: '商品信息',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '下单方式',
|
||||
dataIndex: 'equipmentCategory',
|
||||
key: 'equipmentCategory'
|
||||
},
|
||||
{
|
||||
title: '电池型号',
|
||||
dataIndex: 'batteryModel',
|
||||
key: 'batteryModel'
|
||||
},
|
||||
{
|
||||
title: '电池价格',
|
||||
dataIndex: 'batteryPrice',
|
||||
key: 'batteryPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '电池租金',
|
||||
dataIndex: 'batteryRent',
|
||||
key: 'batteryRent',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '分期方案',
|
||||
dataIndex: 'more',
|
||||
key: 'more'
|
||||
},
|
||||
{
|
||||
title: '购买数量',
|
||||
dataIndex: 'num',
|
||||
key: 'num',
|
||||
customRender: ({}) => 1
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格实例
|
||||
const tableRef2 = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
const columns2 = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '当前期数',
|
||||
dataIndex: 'index',
|
||||
key: 'index',
|
||||
customRender: ({ index }) => {
|
||||
return '第' + (index + 1) + '期';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '订单金额',
|
||||
dataIndex: 'orderPrice',
|
||||
key: 'orderPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '设备租金',
|
||||
dataIndex: 'batteryModel',
|
||||
key: 'batteryModel'
|
||||
},
|
||||
{
|
||||
title: '有效期限',
|
||||
dataIndex: 'expirationTime',
|
||||
key: 'expirationTime'
|
||||
},
|
||||
{
|
||||
title: '付款时间',
|
||||
dataIndex: 'payTime',
|
||||
key: 'payTime'
|
||||
},
|
||||
{
|
||||
title: '逾期状态',
|
||||
dataIndex: 'expirationDay',
|
||||
key: 'expirationDay'
|
||||
}
|
||||
]);
|
||||
const columns3 = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode'
|
||||
},
|
||||
{
|
||||
title: '所属门店',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName'
|
||||
},
|
||||
{
|
||||
title: '事件类型',
|
||||
dataIndex: 'eventType',
|
||||
key: 'eventType'
|
||||
},
|
||||
{
|
||||
title: '使用电池',
|
||||
dataIndex: 'use'
|
||||
},
|
||||
{
|
||||
title: '操作人',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname'
|
||||
},
|
||||
{
|
||||
title: '操作时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime'
|
||||
}
|
||||
]);
|
||||
|
||||
/* 制作步骤条 */
|
||||
const loadSteps = (order) => {
|
||||
steps.value = [];
|
||||
steps.value.push({
|
||||
title: '下单'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '付款'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '发货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '收货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '完成'
|
||||
});
|
||||
|
||||
// 下单
|
||||
if (order.payStatus == 10) {
|
||||
active.value = 0;
|
||||
steps.value[0].description = order.createTime;
|
||||
}
|
||||
// 付款
|
||||
if (order.payStatus == 20) {
|
||||
active.value = 1;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
}
|
||||
// 发货
|
||||
if (order.payStatus == 20 && order.deliveryStatus == 20) {
|
||||
active.value = 2;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
}
|
||||
// 收货
|
||||
if (order.payStatus == 20 && order.receiptStatus == 20) {
|
||||
active.value = 3;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 完成
|
||||
if (order.payStatus == 20 && order.orderStatus == 30) {
|
||||
active.value = 4;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 已取消
|
||||
if (order.orderStatus == 20) {
|
||||
active.value = 4;
|
||||
}
|
||||
};
|
||||
|
||||
const getEquipmentOrderGoods = () => {
|
||||
const orderId = props.data?.orderId;
|
||||
const goodsId = props.data?.goodsId;
|
||||
listEquipmentOrderGoods({ orderId,goodsId }).then((data) => {
|
||||
EquipmentOrderGoodsList.value = data;
|
||||
});
|
||||
};
|
||||
|
||||
const getEquipment = () => {
|
||||
EquipmentApi.listEquipment({ orderId: order.orderId }).then((data) => {
|
||||
if (data.length > 0) {
|
||||
bindEquipmentCode.value = data[0].equipmentCode;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getRenewOrder = () => {
|
||||
loading.value = true;
|
||||
listOrder({
|
||||
rentOrderId: order.orderId,
|
||||
payStatus: 20
|
||||
}).then((data) => {
|
||||
renewOrderList.value = data;
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const getEquipmentRecordList = () => {
|
||||
EquipmentRecordApi.listEquipmentRecord({
|
||||
orderId: order.orderId,
|
||||
userId: order.userId
|
||||
}).then((data) => {
|
||||
equipmentRecordList.value = data;
|
||||
});
|
||||
};
|
||||
|
||||
const expirationDay = (order) => {
|
||||
const setTime = new Date(order.expirationTime);
|
||||
const nowTime = new Date(order.payTime);
|
||||
const restSec = setTime.getTime() - nowTime.getTime();
|
||||
// 剩余天数
|
||||
const day = parseInt(String(restSec / (60 * 60 * 24 * 1000)));
|
||||
if (day < 0) {
|
||||
return '逾期' + Math.abs(day) + '天';
|
||||
}
|
||||
};
|
||||
|
||||
const getFiles = () => {
|
||||
if (order.orderSourceData != '') {
|
||||
const array = JSON.parse(<string>order.orderSourceData);
|
||||
files.value = array.map((url, id) => {
|
||||
return {
|
||||
id: id,
|
||||
url: url,
|
||||
status: 'done'
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignObject(order, props.data);
|
||||
loadSteps(props.data);
|
||||
getFiles();
|
||||
getEquipmentOrderGoods();
|
||||
getRenewOrder();
|
||||
getEquipment();
|
||||
getEquipmentRecordList();
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.order-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ant-form-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
159
src/views/yunxinwei/order/components/search.vue
Normal file
159
src/views/yunxinwei/order/components/search.vue
Normal file
@@ -0,0 +1,159 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-radio-group v-model:value="listType" @change="handleTabs">
|
||||
<a-radio-button :value="0">全部订单</a-radio-button>
|
||||
<a-radio-button :value="1">待发货</a-radio-button>
|
||||
<a-radio-button :value="2">待收货</a-radio-button>
|
||||
<a-radio-button :value="3">待付款</a-radio-button>
|
||||
<a-radio-button :value="4">已完成</a-radio-button>
|
||||
<a-radio-button :value="5">已取消</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="searchText"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 100px; margin: -5px -12px">
|
||||
<a-select-option value="keywords">模糊搜索</a-select-option>
|
||||
<a-select-option value="orderNo">订单号</a-select-option>
|
||||
<a-select-option value="merchantCode">商户编号</a-select-option>
|
||||
<a-select-option value="userId">用户ID</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderParam } from '@/api/order/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: OrderParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<OrderParam>({
|
||||
orderNo: undefined,
|
||||
userId: undefined,
|
||||
payStatus: undefined,
|
||||
deliveryStatus: undefined,
|
||||
orderStatus: undefined
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('keywords');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
const listType = ref<number>(0);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
if (type.value == 'orderNo') {
|
||||
where.orderNo = searchText.value;
|
||||
where.userId = undefined;
|
||||
}
|
||||
if (type.value == 'userId') {
|
||||
where.userId = searchText.value;
|
||||
where.orderNo = undefined;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
where.orderNo = undefined;
|
||||
}
|
||||
if (type.value == 'keywords') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
emit('search', {
|
||||
...where,
|
||||
createTimeStart: d1 ? d1 + ' 00:00:00' : '',
|
||||
createTimeEnd: d2 ? d2 + ' 23:59:59' : ''
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
resetFields();
|
||||
const listType = Number(e.target.value);
|
||||
// 全部订单
|
||||
if (listType == 0) {
|
||||
console.log('全部订单');
|
||||
}
|
||||
// 待发货
|
||||
if (listType == 1) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 10;
|
||||
}
|
||||
// 待收货
|
||||
if (listType == 2) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 20;
|
||||
where.receiptStatus = 10;
|
||||
}
|
||||
// 待付款
|
||||
if (listType == 3) {
|
||||
console.log('待付款');
|
||||
where.payStatus = 10;
|
||||
}
|
||||
// 已完成
|
||||
if (listType == 4) {
|
||||
console.log('已完成');
|
||||
where.payStatus = 20;
|
||||
where.orderStatus = 30;
|
||||
}
|
||||
// 已取消
|
||||
if (listType == 5) {
|
||||
console.log('已取消');
|
||||
where.orderStatus = 20;
|
||||
}
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
545
src/views/yunxinwei/order/index.vue
Normal file
545
src/views/yunxinwei/order/index.vue
Normal file
@@ -0,0 +1,545 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="orderId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@advanced="openAdvanced"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'merchantName'">
|
||||
<div style="display: flex; flex-direction: column">
|
||||
<span>{{ record.merchantName }}</span>
|
||||
<span class="ele-text-placeholder">
|
||||
{{ record.merchantCode }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'totalPrice'">
|
||||
<p>
|
||||
<span class="ele-text-warning price-edit">
|
||||
¥{{ record.totalPrice }}
|
||||
</span>
|
||||
<form-outlined
|
||||
v-if="record.payStatus === 10"
|
||||
@click="onEdit('totalPrice', record.totalPrice, record)"
|
||||
/></p>
|
||||
<p class="ele-text-placeholder"
|
||||
>(含运费:¥{{ record.expressPrice }})</p
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'goods'">
|
||||
<template v-if="record.equipment">
|
||||
<p class="ele-text">{{ record.equipment.equipmentName }}</p>
|
||||
<p class="ele-text">{{ record.equipment.batteryModel }}</p>
|
||||
<p class="ele-text">{{ record.equipment.equipmentCode }}</p>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'payMethod'">
|
||||
<a-tag v-if="record.payMethod === '10'" color="orange"
|
||||
>余额支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '20'" color="green"
|
||||
>微信支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '30'" color="blue"
|
||||
>支付宝</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '40'" color="purple"
|
||||
>通联支付</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryType'">
|
||||
<span v-if="record.deliveryType === 10">快递配送</span>
|
||||
<span v-if="record.deliveryType === 20">门店自提</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'payStatus'">
|
||||
<div class="ele-text-placeholder">
|
||||
付款状态:
|
||||
<a-tag
|
||||
v-if="record.payStatus === 10"
|
||||
@click="onAlipayQuery(record.orderId)"
|
||||
>未付款</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payStatus === 20" color="green"
|
||||
>已付款</a-tag
|
||||
>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
发货状态:
|
||||
<a-tag v-if="record.deliveryStatus === 10">未发货</a-tag>
|
||||
<a-tag v-if="record.deliveryStatus === 20" color="success"
|
||||
>已发货</a-tag
|
||||
>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
收货状态:
|
||||
<a-tag v-if="record.receiptStatus === 10">未收货</a-tag>
|
||||
<a-tag v-if="record.receiptStatus === 20" color="success"
|
||||
>已收货</a-tag
|
||||
>
|
||||
<a-tag v-if="record.receiptStatus === 30" color="error"
|
||||
>已退租</a-tag
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<FormOutlined
|
||||
@click="onEditContent('comments', record.comments, record)"
|
||||
/>
|
||||
<a-popover placement="topLeft">
|
||||
<template #content>
|
||||
<div class="comments">{{ record.comments }}</div>
|
||||
</template>
|
||||
{{ record.comments }}
|
||||
</a-popover>
|
||||
</template>
|
||||
<template v-if="column.key === 'orderSourceData'">
|
||||
<a-image-preview-group v-if="record.orderSourceData">
|
||||
<a-image
|
||||
:width="45"
|
||||
v-for="(item, index) in JSON.parse(record.orderSourceData)"
|
||||
:key="index"
|
||||
:src="item"
|
||||
/>
|
||||
</a-image-preview-group>
|
||||
<!-- <a-image-->
|
||||
<!-- v-if="record.orderSourceData"-->
|
||||
<!-- :src="JSON.parse(record.orderSourceData)"-->
|
||||
<!-- :width="45"-->
|
||||
<!-- />-->
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === '0'" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === '1'" color="red">禁用</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'orderSource'">
|
||||
<a-tag v-if="Number(record.orderSource) === 10" color="success"
|
||||
>销售</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 20" color="red"
|
||||
>分期</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 30" color="orange"
|
||||
>以租代购</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 40" color="blue"
|
||||
>租赁</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 50" color="success"
|
||||
>续租</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<User :record="record" />
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openInfo(record)">详情</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Delivery v-model:visible="deliveryEdit" :data="current" @done="reload" />
|
||||
<Markdown
|
||||
v-model:visible="showMarkdown"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="markdown"
|
||||
@done="reload"
|
||||
/>
|
||||
<Field
|
||||
v-model:visible="showEdit"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="content"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 编辑弹窗 -->
|
||||
<!-- <order-edit v-model:visible="showEdit" :data="current" @done="reload" />-->
|
||||
<!-- 用户详情 -->
|
||||
<order-info v-model:visible="showInfo" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
// PlusOutlined,
|
||||
// DeleteOutlined,
|
||||
FormOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Delivery from './components/delivery.vue';
|
||||
import Markdown from './components/markdown.vue';
|
||||
import Field from './components/field.vue';
|
||||
import OrderInfo from './components/order-info.vue';
|
||||
import { pageOrder, removeOrder, removeBatchOrder } from '@/api/order';
|
||||
import { alipayQuery } from '@/api/system/payment';
|
||||
import type { Order, OrderParam } from '@/api/order/model';
|
||||
import { getDictionaryOptions } from '@/utils/common';
|
||||
|
||||
// 当前用户信息
|
||||
// const userStore = useUserStore();
|
||||
// const loginUser = computed(() => userStore.info ?? {});
|
||||
// const orderType = localStorage.getItem('orderType');
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
/* 获取字典数据 */
|
||||
const orderSource = getDictionaryOptions('equipmentCategory');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: 'orderId',
|
||||
key: 'orderId',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '商品编号',
|
||||
dataIndex: 'goodsId',
|
||||
key: 'goodsId'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '下单方式',
|
||||
key: 'orderSource',
|
||||
dataIndex: 'orderSource',
|
||||
filters: orderSource,
|
||||
filterMultiple: false
|
||||
},
|
||||
{
|
||||
title: '买家',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单金额(元)',
|
||||
dataIndex: 'totalPrice',
|
||||
key: 'totalPrice',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '支付方式',
|
||||
key: 'payMethod',
|
||||
dataIndex: 'payMethod',
|
||||
filters: [
|
||||
{
|
||||
text: '余额支付',
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
text: '微信支付',
|
||||
value: 20
|
||||
},
|
||||
{
|
||||
text: '支付宝',
|
||||
value: 30
|
||||
},
|
||||
{
|
||||
text: '通联支付',
|
||||
value: 40
|
||||
}
|
||||
],
|
||||
filterMultiple: false
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
ellipsis: true
|
||||
},
|
||||
// {
|
||||
// title: '订单附件',
|
||||
// dataIndex: 'orderSourceData',
|
||||
// key: 'orderSourceData'
|
||||
// },
|
||||
{
|
||||
title: '配送方式',
|
||||
key: 'deliveryType',
|
||||
dataIndex: 'deliveryType',
|
||||
hideInTable: true,
|
||||
filters: [
|
||||
{
|
||||
text: '快递配送',
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
text: '门店自提',
|
||||
value: 20
|
||||
}
|
||||
],
|
||||
filterMultiple: false
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '交易状态',
|
||||
key: 'payStatus',
|
||||
dataIndex: 'payStatus',
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
filters: [
|
||||
{
|
||||
text: '未付款',
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
text: '已付款',
|
||||
value: 20
|
||||
}
|
||||
],
|
||||
filterMultiple: false
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Order[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Order | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const markdown = ref('请输入备注内容');
|
||||
const content = ref('请输入要修改的内容');
|
||||
const showMarkdown = ref(false);
|
||||
const deliveryEdit = ref(false);
|
||||
const field = ref('comments');
|
||||
const orderId = ref(undefined);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
where.isRenew = 0;
|
||||
return pageOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: OrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
const onEdit = (name, text, item) => {
|
||||
orderId.value = item.orderId;
|
||||
field.value = name;
|
||||
content.value = text;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onEditContent = (name, text, item) => {
|
||||
orderId.value = item.orderId;
|
||||
field.value = name;
|
||||
markdown.value = text;
|
||||
showMarkdown.value = true;
|
||||
};
|
||||
|
||||
const openDelivery = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
deliveryEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
/* 支付宝统一收单交易查询 */
|
||||
const onAlipayQuery = (orderNo) => {
|
||||
alipayQuery(orderNo).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Order) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeOrder(row.orderId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchOrder(selection.value.map((d) => d.orderId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Order) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openInfo(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopOrderIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
39
src/views/yunxinwei/record/components/category-select.vue
Normal file
39
src/views/yunxinwei/record/components/category-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 目录选择下拉框 -->
|
||||
<template>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:placeholder="placeholder"
|
||||
:value="value || undefined"
|
||||
:tree-data="data"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Equipment } from '@/api/apps/equipment/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value?: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据(v-modal)
|
||||
value?: number;
|
||||
// 提示信息
|
||||
placeholder?: string;
|
||||
// 文章分类
|
||||
data: Equipment[];
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择上级分类'
|
||||
}
|
||||
);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value?: number) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
339
src/views/yunxinwei/record/components/edit.vue
Normal file
339
src/views/yunxinwei/record/components/edit.vue
Normal file
@@ -0,0 +1,339 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑' : '新建'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="选择设备" name="equipmentCode">
|
||||
<EquipmentSelect
|
||||
dict-code="equipmentCode"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="事件类型" name="eventType">
|
||||
<DictSelect
|
||||
dict-code="eventType"
|
||||
v-model:value="form.eventType"
|
||||
placeholder="选择事件类型"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="上传图片" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="1"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="设备参数" name="params">
|
||||
<a-textarea
|
||||
:rows="10"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.params"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { EquipmentRecord } from '@/api/apps/equipment/record/model';
|
||||
import {
|
||||
addEquipmentRecord,
|
||||
updateEquipmentRecord
|
||||
} from '@/api/apps/equipment/record';
|
||||
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: EquipmentRecord | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<EquipmentRecord>({
|
||||
id: undefined,
|
||||
equipmentCode: undefined,
|
||||
eventType: undefined,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
merchantCode: undefined
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择设备',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
eventType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择事件类型',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
params: [
|
||||
{
|
||||
required: true,
|
||||
message: '请填写设备参数',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入文章内容',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == '') {
|
||||
return Promise.reject('请输入文字内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipmentRecord(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentFaultForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateEquipmentRecord
|
||||
: addEquipmentRecord;
|
||||
saveOrUpdate(equipmentFaultForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
// images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
144
src/views/yunxinwei/record/components/search.vue
Normal file
144
src/views/yunxinwei/record/components/search.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<!-- <a-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- v-permission="'apps:equipment:save'"-->
|
||||
<!-- @click="add"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>新建</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
v-if="props.selection.length > 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-radio-group v-model:value="listType" @change="handleTabs">-->
|
||||
<!-- <a-radio-button value="all">全部</a-radio-button>-->
|
||||
<!-- <a-radio-button value="onSale">出售中</a-radio-button>-->
|
||||
<!-- <a-radio-button value="offSale">已下架</a-radio-button>-->
|
||||
<!-- <a-radio-button value="soldOut">已售罄</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="equipmentName">设备名称</a-select-option>
|
||||
<a-select-option value="userId">操作人ID</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
userId: undefined
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
resetFields();
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'userId') {
|
||||
where.userId = Number(searchText.value);
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// listType.value = e.target.value;
|
||||
// if (listType.value == 'all') {
|
||||
// resetFields();
|
||||
// }
|
||||
// if (listType.value == 'onSale') {
|
||||
// where.status = 0;
|
||||
// }
|
||||
// if (listType.value == 'offSale') {
|
||||
// where.status = 1;
|
||||
// }
|
||||
// if (listType.value == 'soldOut') {
|
||||
// where.stockTotal = 0;
|
||||
// }
|
||||
// emit('search', where);
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
299
src/views/yunxinwei/record/index.vue
Normal file
299
src/views/yunxinwei/record/index.vue
Normal file
@@ -0,0 +1,299 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="前世今生">
|
||||
<div class="ele-text-secondary"> 记录设备的事件明细。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="80" />
|
||||
</template>
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<!-- <a @click="openEdit(record)">{{ record.equipmentCode }}</a>-->
|
||||
<span>{{ record.equipmentCode }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'eventType'">
|
||||
{{ record.eventType }}
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<a-tooltip
|
||||
:title="`用户ID:${record.userId}`"
|
||||
placement="topLeft"
|
||||
>
|
||||
{{ record.nickname }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'params'">
|
||||
<a-tooltip :title="record.params" placement="topLeft">
|
||||
{{ record.params }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageEquipmentRecord,
|
||||
removeEquipmentRecord,
|
||||
removeBatchEquipmentRecord
|
||||
} from '@/api/apps/equipment/record';
|
||||
import type {
|
||||
EquipmentRecord,
|
||||
EquipmentRecordParam
|
||||
} from '@/api/apps/equipment/record/model';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode',
|
||||
width: 180,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '操作人',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '所属门店',
|
||||
dataIndex: 'merchantName',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '事件类型',
|
||||
dataIndex: 'eventType',
|
||||
key: 'eventType',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '使用电池',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
ellipsis: true
|
||||
},
|
||||
// {
|
||||
// title: '设备参数',
|
||||
// dataIndex: 'params',
|
||||
// key: 'params',
|
||||
// ellipsis: true
|
||||
// },
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
width: 280,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 200,
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<EquipmentRecord[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<EquipmentRecord | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageEquipmentRecord({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentRecordParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: EquipmentRecord) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: EquipmentRecord) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: EquipmentRecord) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeEquipmentRecord(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipmentRecord(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentRecordIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
145
src/views/yunxinwei/refund/components/edit.vue
Normal file
145
src/views/yunxinwei/refund/components/edit.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="500"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '发货' : '发货'"
|
||||
:body-style="{ paddingBottom: '24px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form>
|
||||
<a-form-item label="审核状态">
|
||||
<a-radio-group
|
||||
v-model:value="form.auditStatus"
|
||||
>
|
||||
<a-radio :value="20">审核通过</a-radio>
|
||||
<a-radio :value="30">驳回</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-alert v-if="form.auditStatus === 20" message="审核通过后,订单将变更为已退租状态,并且电池设备自动解绑。" type="warning" />
|
||||
<a-form-item label="驳回原因" v-if="form.auditStatus === 30">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="仅在驳回时填写"
|
||||
v-model:value="form.refuseDesc"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { OrderRefund } from "@/api/order/refund/model";
|
||||
import { updateOrderRefund } from "@/api/order/refund";
|
||||
import { assignObject } from "ele-admin-pro";
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: OrderRefund;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<OrderRefund>({
|
||||
orderRefundId: undefined,
|
||||
auditStatus: 20,
|
||||
orderId: undefined,
|
||||
refuseDesc: '',
|
||||
tenantId: undefined
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入设备编码',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
const data = {
|
||||
...form,
|
||||
orderRefundId: props.data?.orderRefundId,
|
||||
orderId: props.data?.orderId,
|
||||
tenantId: props.data?.tenantId
|
||||
};
|
||||
// 转字符串
|
||||
updateOrderRefund(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
if(props.data.auditStatus != 10){
|
||||
assignObject(form, props.data);
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
140
src/views/yunxinwei/refund/components/search.vue
Normal file
140
src/views/yunxinwei/refund/components/search.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="searchText"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
SearchOutlined,
|
||||
DeleteOutlined,
|
||||
UpSquareOutlined,
|
||||
DownSquareOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderParam } from '@/api/order/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: OrderParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<OrderParam>({
|
||||
orderNo: undefined,
|
||||
userId: undefined,
|
||||
payStatus: undefined,
|
||||
deliveryStatus: undefined,
|
||||
orderStatus: undefined
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('orderNo');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
const listType = ref<number>(0);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
if (type.value == 'orderNo') {
|
||||
where.orderNo = searchText.value;
|
||||
where.userId = undefined;
|
||||
}
|
||||
if (type.value == 'userId') {
|
||||
where.userId = searchText.value;
|
||||
where.orderNo = undefined;
|
||||
}
|
||||
console.log(where);
|
||||
emit('search', {
|
||||
...where,
|
||||
createTimeStart: d1 ? d1 + ' 00:00:00' : '',
|
||||
createTimeEnd: d2 ? d2 + ' 23:59:59' : ''
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
resetFields();
|
||||
const listType = Number(e.target.value);
|
||||
console.log(listType);
|
||||
// 全部订单
|
||||
if (listType == 0) {
|
||||
console.log('全部订单');
|
||||
}
|
||||
// 待发货
|
||||
if (listType == 1) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 10;
|
||||
}
|
||||
// 待收货
|
||||
if (listType == 2) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 20;
|
||||
where.receiptStatus = 10;
|
||||
}
|
||||
// 待付款
|
||||
if (listType == 3) {
|
||||
console.log('待付款');
|
||||
where.payStatus = 10;
|
||||
}
|
||||
// 已完成
|
||||
if (listType == 4) {
|
||||
console.log('已完成');
|
||||
where.payStatus = 20;
|
||||
where.orderStatus = 30;
|
||||
}
|
||||
// 已取消
|
||||
if (listType == 5) {
|
||||
console.log('已取消');
|
||||
where.orderStatus = 20;
|
||||
}
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
294
src/views/yunxinwei/refund/index.vue
Normal file
294
src/views/yunxinwei/refund/index.vue
Normal file
@@ -0,0 +1,294 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="orderRefundId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@advanced="openAdvanced"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goods'">
|
||||
<template v-if="record.equipment">
|
||||
<p class="ele-text">{{ record.equipment.equipmentName }}</p>
|
||||
<p class="ele-text">{{ record.equipment.batteryModel }}</p>
|
||||
<p class="ele-text">{{ record.equipment.equipmentCode }}</p>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryType'">
|
||||
<span v-if="record.deliveryType === 10">快递配送</span>
|
||||
<span v-if="record.deliveryType === 20">门店自提</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'auditStatus'">
|
||||
<a-tag v-if="record.auditStatus === 10" color="orange"
|
||||
>待审核</a-tag
|
||||
>
|
||||
<a-tag v-if="record.auditStatus === 20" color="green"
|
||||
>已同意</a-tag
|
||||
>
|
||||
<a-tag v-if="record.auditStatus === 30" color="red">已拒绝</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'orderSource'">
|
||||
<span v-if="record.orderSource === 10" color="green"
|
||||
>普通订单</span
|
||||
>
|
||||
<span v-if="record.orderSource === 20" color="red">禁用</span>
|
||||
<span v-if="record.orderSource === 30" color="red">禁用</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<a-tooltip :title="`用户ID:${record.userId}`">
|
||||
<a-avatar :src="record.avatar" size="small" />
|
||||
<span style="padding-left: 4px">{{ record.nickname }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openEdit(record)">审核</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageOrderRefund,
|
||||
removeOrderRefund,
|
||||
removeBatchOrderRefund
|
||||
} from '@/api/order/refund';
|
||||
import type { OrderRefund, OrderRefundParam } from '@/api/order/refund/model';
|
||||
|
||||
const props = defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
/* 获取字典数据 */
|
||||
// const payMethodDict = getDictionaryOptions('payMethod');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: 'orderId',
|
||||
key: 'orderId'
|
||||
},
|
||||
{
|
||||
title: '买家',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname'
|
||||
},
|
||||
{
|
||||
title: '用户申请原因',
|
||||
dataIndex: 'applyDesc',
|
||||
key: 'applyDesc',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
key: 'auditStatus',
|
||||
dataIndex: 'auditStatus'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<OrderRefund[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<OrderRefund | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const deliveryEdit = ref(false);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
where.isRenew = 0;
|
||||
console.log('isRenew');
|
||||
return pageOrderRefund({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: OrderRefundParam) => {
|
||||
console.log(where, '....>>>>111');
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
const openDelivery = (row?: OrderRefund) => {
|
||||
current.value = row ?? null;
|
||||
deliveryEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: OrderRefund) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: OrderRefund) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: OrderRefund) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeOrderRefund(row.orderRefundId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchOrderRefund(selection.value.map((d) => d.orderRefundId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopOrderRefundIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
186
src/views/yunxinwei/renew/components/delivery.vue
Normal file
186
src/views/yunxinwei/renew/components/delivery.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="500"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '发货' : '发货'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-space>
|
||||
<a-form>
|
||||
<a-form-item label="设备编码" v-bind="validateInfos.equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
placeholder="请输入设备编码"
|
||||
v-model:value="form.equipmentCode"
|
||||
@blur="
|
||||
validate('equipmentCode', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-row :gutter="16">-->
|
||||
<!-- <a-col :md="12" :sm="24" :xs="24">-->
|
||||
<!-- <a-form-item label="选择设备" v-bind="validateInfos.customerName">-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :maxlength="30"-->
|
||||
<!-- placeholder="请选择设备"-->
|
||||
<!-- v-model:value="form.customerName"-->
|
||||
<!-- @blur="-->
|
||||
<!-- validate('customerName', { trigger: 'blur' }).catch(() => {})-->
|
||||
<!-- "-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- <a-col :md="12" :sm="24" :xs="24">-->
|
||||
<!-- <a-form-item label="手机号码" v-bind="validateInfos.customerMobile">-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :maxlength="20"-->
|
||||
<!-- placeholder="请填写联系人手机号码"-->
|
||||
<!-- v-model:value="form.customerMobile"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- </a-row>-->
|
||||
</a-form>
|
||||
</a-space>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import TypeSelect from './customer-edit/type-select.vue';
|
||||
import ProgressSelect from './customer-edit/progress-select.vue';
|
||||
import SourceSelect from './customer-edit/source-select.vue';
|
||||
import { bindEquipment } from '@/api/apps/equipment';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { createCode } from '@/utils/common';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import type { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { Equipment } from "@/api/apps/equipment/model";
|
||||
import { Order } from "@/api/order/model";
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Equipment>({
|
||||
equipmentCode: '',
|
||||
orderId: undefined
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入设备编码',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
const data = {
|
||||
...form,
|
||||
orderId: props.data?.orderId,
|
||||
userId: props.data?.userId
|
||||
};
|
||||
// 转字符串
|
||||
bindEquipment(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.customerAvatar = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.customerAvatar){
|
||||
images.value.push({ uid:1, url: FILE_SERVER + props.data.customerAvatar, status: '' });
|
||||
}
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.customerCode = createCode();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
118
src/views/yunxinwei/renew/components/field.vue
Normal file
118
src/views/yunxinwei/renew/components/field.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="500px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改价格`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form layout="horizontal">
|
||||
<a-form-item>
|
||||
<a-input-number :min="0" style="width: 200px" v-model:value="content" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { createOrderNo } from "@/utils/common";
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
orderId?: number | 0;
|
||||
content?: number | 0;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref<number>(0);
|
||||
const placeholder = ref('请输入订单金额');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: '',
|
||||
payPrice: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'payPrice') {
|
||||
form.payPrice = Number(content.value);
|
||||
form.totalPrice = Number(content.value);
|
||||
form.orderNo = createOrderNo();
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.orderId) {
|
||||
loading.value = false;
|
||||
content.value = props.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
|
||||
if (props.field == 'tenantCode') {
|
||||
placeholder.value = '请输入要绑定的主体编号';
|
||||
content.value = undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
139
src/views/yunxinwei/renew/components/markdown.vue
Normal file
139
src/views/yunxinwei/renew/components/markdown.vue
Normal file
@@ -0,0 +1,139 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="600px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改内容`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- 编辑器 -->
|
||||
<byte-md-editor
|
||||
v-model:value="content"
|
||||
:locale="zh_Hans"
|
||||
:plugins="plugins"
|
||||
uploadImages
|
||||
height="300px"
|
||||
:editorConfig="{ lineNumbers: true }"
|
||||
/>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
import 'bytemd/dist/index.min.css';
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
// import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
import ByteMdEditor from '@/components/ByteMdEditor/index.vue';
|
||||
import highlight from '@bytemd/plugin-highlight';
|
||||
// 中文语言文件
|
||||
import zh_Hans from 'bytemd/locales/zh_Hans.json';
|
||||
// // 链接、删除线、复选框、表格等的插件
|
||||
import gfm from '@bytemd/plugin-gfm';
|
||||
// // 插件的中文语言文件
|
||||
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
|
||||
// // 预览界面的样式,这里用的 github 的 markdown 主题
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
content?: string;
|
||||
orderId?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 插件
|
||||
const plugins = ref([
|
||||
gfm({
|
||||
locale: zh_HansGfm
|
||||
}),
|
||||
highlight()
|
||||
]);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref('');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: ''
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'content') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
if (props.field === 'comments') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
content.value = String(props.content);
|
||||
console.log(visible);
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
content.value = String(props.content);
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
289
src/views/yunxinwei/renew/components/order-edit.vue
Normal file
289
src/views/yunxinwei/renew/components/order-edit.vue
Normal file
@@ -0,0 +1,289 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="680"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑订单' : '添加订单'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-space>
|
||||
<a-form
|
||||
:label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="订单名称" v-bind="validateInfos.customerName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
placeholder="请输入订单名称"
|
||||
v-model:value="form.customerName"
|
||||
@blur="
|
||||
validate('customerName', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单标识" v-bind="validateInfos.customerCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入用户账号"
|
||||
v-model:value="form.customerCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="跟进状态" v-bind="validateInfos.progress">
|
||||
<progress-select
|
||||
v-model:value="form.progress"
|
||||
@blur="
|
||||
validate('progress', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单类型" v-bind="validateInfos.customerType">
|
||||
<type-select
|
||||
v-model:value="form.customerType"
|
||||
@blur="
|
||||
validate('customerType', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单来源" v-bind="validateInfos.customerSource">
|
||||
<source-select
|
||||
v-model:value="form.customerSource"
|
||||
@blur="
|
||||
validate('customerSource', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="头像" v-bind="validateInfos.customerAvatar">
|
||||
<ele-image-upload
|
||||
v-model:value="images"
|
||||
:item-style="{ width: '90px', height: '90px' }"
|
||||
:limit="1"
|
||||
@upload="onUpload"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="联系人" v-bind="validateInfos.customerContacts">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人"
|
||||
v-model:value="form.customerContacts"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="手机号码" v-bind="validateInfos.customerMobile">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人手机号码"
|
||||
v-model:value="form.customerMobile"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="联系地址"
|
||||
v-bind="validateInfos.customerAddress"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请填写联系地址"
|
||||
v-model:value="form.customerAddress"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="公司座机" v-bind="validateInfos.customerPhone">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写公司座机电话"
|
||||
v-model:value="form.customerPhone"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" v-bind="validateInfos.sortNumber">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="排序"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" v-bind="validateInfos.comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-space>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import TypeSelect from './customer-edit/type-select.vue';
|
||||
import ProgressSelect from './customer-edit/progress-select.vue';
|
||||
import SourceSelect from './customer-edit/source-select.vue';
|
||||
import { addCustomer, updateCustomer } from '@/api/oa/customer';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { createCode } from '@/utils/common';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import type { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Customer | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Customer>({
|
||||
customerCode: '',
|
||||
customerName: '',
|
||||
customerType: undefined,
|
||||
progress: undefined,
|
||||
customerMobile: '',
|
||||
customerAvatar: '',
|
||||
customerPhone: '',
|
||||
customerContacts: '',
|
||||
customerAddress: '',
|
||||
comments: '',
|
||||
status: '0',
|
||||
sortNumber: 100,
|
||||
customerId: 0,
|
||||
userId: '',
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
customerName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入订单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
customerCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入合法的IP地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
progress: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择跟进状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
form.customerName = form.customerName?.replace(/\s*/g, '');
|
||||
if(isUpdate.value == false) {
|
||||
form.userId = loginUser.value.userId;
|
||||
}
|
||||
const data = {
|
||||
...form
|
||||
};
|
||||
// 转字符串
|
||||
const saveOrUpdate = isUpdate.value ? updateCustomer : addCustomer;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.customerAvatar = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.customerAvatar){
|
||||
images.value.push({ uid:1, url: FILE_SERVER + props.data.customerAvatar, status: '' });
|
||||
}
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.customerCode = createCode();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
164
src/views/yunxinwei/renew/components/search.vue
Normal file
164
src/views/yunxinwei/renew/components/search.vue
Normal file
@@ -0,0 +1,164 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-radio-group v-model:value="listType" @change="handleTabs">
|
||||
<a-radio-button :value="0">全部订单</a-radio-button>
|
||||
<a-radio-button :value="1">待发货</a-radio-button>
|
||||
<a-radio-button :value="2">待收货</a-radio-button>
|
||||
<a-radio-button :value="3">待付款</a-radio-button>
|
||||
<a-radio-button :value="4">已完成</a-radio-button>
|
||||
<a-radio-button :value="5">已取消</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="searchText"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 100px; margin: -5px -12px">
|
||||
<a-select-option value="orderNo">订单号</a-select-option>
|
||||
<a-select-option value="merchantCode">商户编号</a-select-option>
|
||||
<a-select-option value="userId">用户ID</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
SearchOutlined,
|
||||
DeleteOutlined,
|
||||
UpSquareOutlined,
|
||||
ShopOutlined,
|
||||
DownSquareOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderParam } from '@/api/order/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: OrderParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<OrderParam>({
|
||||
orderNo: undefined,
|
||||
userId: undefined,
|
||||
payStatus: undefined,
|
||||
deliveryStatus: undefined,
|
||||
orderStatus: undefined
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('orderNo');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
const listType = ref<number>(0);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
if (type.value == 'orderNo') {
|
||||
where.orderNo = searchText.value;
|
||||
where.userId = undefined;
|
||||
}
|
||||
if (type.value == 'userId') {
|
||||
where.userId = searchText.value;
|
||||
where.orderNo = undefined;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
where.orderNo = undefined;
|
||||
}
|
||||
emit('search', {
|
||||
...where,
|
||||
createTimeStart: d1 ? d1 + ' 00:00:00' : '',
|
||||
createTimeEnd: d2 ? d2 + ' 23:59:59' : ''
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
resetFields();
|
||||
const listType = Number(e.target.value);
|
||||
// 全部订单
|
||||
if (listType == 0) {
|
||||
console.log('全部订单');
|
||||
}
|
||||
// 待发货
|
||||
if (listType == 1) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 10;
|
||||
}
|
||||
// 待收货
|
||||
if (listType == 2) {
|
||||
console.log('待发货');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 20;
|
||||
where.receiptStatus = 10;
|
||||
}
|
||||
// 待付款
|
||||
if (listType == 3) {
|
||||
console.log('待付款');
|
||||
where.payStatus = 10;
|
||||
}
|
||||
// 已完成
|
||||
if (listType == 4) {
|
||||
console.log('已完成');
|
||||
where.payStatus = 20;
|
||||
where.orderStatus = 30;
|
||||
}
|
||||
// 已取消
|
||||
if (listType == 5) {
|
||||
console.log('已取消');
|
||||
where.orderStatus = 20;
|
||||
}
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
494
src/views/yunxinwei/renew/index.vue
Normal file
494
src/views/yunxinwei/renew/index.vue
Normal file
@@ -0,0 +1,494 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="orderId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 2000 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@advanced="openAdvanced"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'orderName'">
|
||||
<a-tooltip title="查看详情">
|
||||
<a href="#" @click="openInfo(record)">{{ record.orderName }}</a>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'merchantName'">
|
||||
<div style="display: flex; flex-direction: column">
|
||||
<span>{{ record.merchantName }}</span>
|
||||
<span class="ele-text-placeholder">
|
||||
{{ record.merchantCode }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'payPrice'">
|
||||
<p>
|
||||
<span class="ele-text-warning price-edit">
|
||||
¥{{ record.payPrice }}
|
||||
</span>
|
||||
<form-outlined
|
||||
v-if="record.payStatus === 10"
|
||||
@click="onEdit('payPrice', record.payPrice, record)"
|
||||
/></p>
|
||||
<p class="ele-text-placeholder"
|
||||
>(含运费:¥{{ record.expressPrice }})</p
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'goods'">
|
||||
<template v-if="record.equipment">
|
||||
<p class="ele-text">{{ record.equipment.equipmentName }}</p>
|
||||
<p class="ele-text">{{ record.equipment.batteryModel }}</p>
|
||||
<p class="ele-text">{{ record.equipment.equipmentCode }}</p>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'payMethod'">
|
||||
<a-tag v-if="record.payMethod === '10'" color="orange"
|
||||
>余额支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '20'" color="green"
|
||||
>微信支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '30'" color="blue"
|
||||
>支付宝</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '40'" color="purple"
|
||||
>通联支付</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryType'">
|
||||
<span v-if="record.deliveryType === 10">快递配送</span>
|
||||
<span v-if="record.deliveryType === 20">门店自提</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'payStatus'">
|
||||
<div class="ele-text-placeholder">
|
||||
付款状态:
|
||||
<a-tag
|
||||
v-if="record.payStatus === 10"
|
||||
@click="onAlipayQuery(record.orderId)"
|
||||
>未付款</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payStatus === 20" color="green"
|
||||
>已付款</a-tag
|
||||
>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
发货状态:
|
||||
<a-tag v-if="record.deliveryStatus === 10">未发货</a-tag>
|
||||
<a-tag v-if="record.deliveryStatus === 20" color="success"
|
||||
>已发货</a-tag
|
||||
>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
收货状态:
|
||||
<a-tag v-if="record.receiptStatus === 10">未收货</a-tag>
|
||||
<a-tag v-if="record.receiptStatus === 20" color="success"
|
||||
>已收货</a-tag
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'orderSourceData'">
|
||||
<a-image-preview-group v-if="record.orderSourceData">
|
||||
<a-image
|
||||
:width="45"
|
||||
v-for="item in JSON.parse(record.orderSourceData)"
|
||||
:src="item"
|
||||
/>
|
||||
</a-image-preview-group>
|
||||
<!-- <a-image-->
|
||||
<!-- v-if="record.orderSourceData"-->
|
||||
<!-- :src="JSON.parse(record.orderSourceData)"-->
|
||||
<!-- :width="45"-->
|
||||
<!-- />-->
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === '0'" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === '1'" color="red">禁用</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'orderSource'">
|
||||
<a-tag v-if="Number(record.orderSource) === 10" color="success"
|
||||
>销售</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 20" color="red"
|
||||
>分期</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 30" color="orange"
|
||||
>以租代购</a-tag
|
||||
>
|
||||
<a-tag v-if="Number(record.orderSource) === 40" color="blue"
|
||||
>租赁</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<a-tooltip :title="`用户ID:${record.userId}`">
|
||||
<a-avatar :src="record.avatar" size="small" />
|
||||
<span style="padding-left: 4px">{{ record.nickname }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button
|
||||
@click="openDelivery(record)"
|
||||
v-if="
|
||||
record.orderStatus === 10 &&
|
||||
record.payStatus === 20 &&
|
||||
record.deliveryStatus === 10
|
||||
"
|
||||
>发货</a-button
|
||||
>
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要删除此记录吗?"-->
|
||||
<!-- @confirm="remove(record)"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="ele-text-danger">删除</a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Delivery v-model:visible="deliveryEdit" :data="current" @done="reload" />
|
||||
<Markdown
|
||||
v-model:visible="showMarkdown"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="markdown"
|
||||
@done="reload"
|
||||
/>
|
||||
<Field
|
||||
v-model:visible="showEdit"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="content"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 编辑弹窗 -->
|
||||
<!-- <order-edit v-model:visible="showEdit" :data="current" @done="reload" />-->
|
||||
<!-- 用户详情 -->
|
||||
<!-- <order-info v-model:visible="showInfo" :data="current" @done="reload" />-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
// PlusOutlined,
|
||||
// DeleteOutlined,
|
||||
FormOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Delivery from './components/delivery.vue';
|
||||
import Markdown from './components/markdown.vue';
|
||||
import Field from './components/field.vue';
|
||||
// import OrderEdit from './components/order-edit.vue';
|
||||
// import OrderInfo from './components/order-info.vue';
|
||||
import { pageOrder, removeOrder, removeBatchOrder } from '@/api/order';
|
||||
import { alipayQuery } from '@/api/system/payment';
|
||||
import type { Order, OrderParam } from '@/api/order/model';
|
||||
import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
|
||||
// 当前用户信息
|
||||
// const userStore = useUserStore();
|
||||
// const loginUser = computed(() => userStore.info ?? {});
|
||||
// const orderType = localStorage.getItem('orderType');
|
||||
const props = defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
/* 获取字典数据 */
|
||||
const orderSource = getDictionaryOptions('equipmentCategory');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '买家',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '实付款(元)',
|
||||
dataIndex: 'payPrice',
|
||||
key: 'payPrice',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '支付方式',
|
||||
key: 'payMethod',
|
||||
dataIndex: 'payMethod',
|
||||
filters: [
|
||||
{
|
||||
text: '余额支付',
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
text: '微信支付',
|
||||
value: 20
|
||||
},
|
||||
{
|
||||
text: '支付宝',
|
||||
value: 30
|
||||
},
|
||||
{
|
||||
text: '通联支付',
|
||||
value: 40
|
||||
}
|
||||
],
|
||||
filterMultiple: false
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '交易状态',
|
||||
key: 'payStatus',
|
||||
dataIndex: 'payStatus',
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
filters: [
|
||||
{
|
||||
text: '未付款',
|
||||
value: 10
|
||||
},
|
||||
{
|
||||
text: '已付款',
|
||||
value: 20
|
||||
}
|
||||
],
|
||||
filterMultiple: false
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Order[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Order | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const markdown = ref('请输入备注内容');
|
||||
const content = ref('请输入要修改的内容');
|
||||
const showMarkdown = ref(false);
|
||||
const deliveryEdit = ref(false);
|
||||
const field = ref('comments');
|
||||
const orderId = ref(undefined);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
// 续费订单
|
||||
where.isRenew = 1;
|
||||
return pageOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: OrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
const onEdit = (name, text, item) => {
|
||||
orderId.value = item.orderId;
|
||||
field.value = name;
|
||||
content.value = text;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onEditContent = (name, text, item) => {
|
||||
orderId.value = item.orderId;
|
||||
field.value = name;
|
||||
markdown.value = text;
|
||||
showMarkdown.value = true;
|
||||
};
|
||||
|
||||
const openDelivery = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
deliveryEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
/* 支付宝统一收单交易查询 */
|
||||
const onAlipayQuery = (orderNo) => {
|
||||
alipayQuery(orderNo).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Order) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeOrder(row.orderId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchOrder(selection.value.map((d) => d.orderId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopOrderIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user