351 lines
8.3 KiB
Vue
Raw Normal View History

2025-08-28 17:29:25 +08:00
<template>
2026-02-05 15:13:59 +08:00
<view class="container">
2026-02-10 16:39:04 +08:00
<MBCard>
<uni-forms ref="baseForm" :modelValue="queryParams">
<uni-forms-item label="货主">
2026-02-05 15:13:59 +08:00
<uni-data-select
2026-02-12 14:41:15 +08:00
v-model="queryParams.companyId"
2026-02-05 15:13:59 +08:00
:clear="true"
:localdata="companyOptions"
text-field="deptName"
value-field="deptId"
@change="getTableData"
/>
</uni-forms-item>
2026-02-10 16:39:04 +08:00
<uni-forms-item label="状态">
<uni-data-select
v-model="queryParams.state"
:clear="true"
:localdata="stateList"
@change="getTableData"
></uni-data-select>
</uni-forms-item>
2026-02-10 17:28:08 +08:00
<uni-forms-item label="合同编号" v-if="userType === '01' || userType === '02'" >
2026-02-10 16:39:04 +08:00
<input
v-model="queryParams.contractcode"
class="uni-input custom-input"
placeholder="请输入合同编号"
@confirm="getTableData"/>
</uni-forms-item>
2026-02-10 17:28:08 +08:00
<uni-forms-item label="商业公司" v-if="userType === '00'" >
2026-03-09 08:25:36 +08:00
<uni-data-select
v-model="queryParams.userid"
placeholder="请输入商业公司"
:clear="true"
:localdata="businessCompanyList"
text-field="value"
value-field="label"
@change="getTableData"
></uni-data-select>
2026-02-10 17:28:08 +08:00
</uni-forms-item>
2026-02-05 15:13:59 +08:00
</uni-forms>
2026-02-10 16:39:04 +08:00
<button
type="primary"
@click="gotoNewAdd"
v-if="userType === '01' || userType === '02'"
>
新增
</button>
</MBCard>
<MBLoading v-if="loading"/>
2026-02-05 15:13:59 +08:00
<view v-else>
2026-03-09 08:25:36 +08:00
<ListItem :items="tableData" @refresh="getTableData" :order-type-list="orderTypeList" :user-type="userType" />
2026-02-10 16:39:04 +08:00
<MBPagination
v-if="total > 0"
v-model:limit="paging.pageSize"
v-model:page="paging.pageNum"
:total="total"
@pagination="handleQuery"
/>
2026-02-05 15:13:59 +08:00
</view>
</view>
2025-08-28 17:29:25 +08:00
</template>
<script setup>
2026-03-09 08:25:36 +08:00
import {listproductList, listsalemain,getBusinessList} from "../../../api/orderManager/index.js"
2026-02-05 15:13:59 +08:00
import {computed, getCurrentInstance, onMounted, ref} from "vue"
import {getDicts} from "../../../api/system/dict/data.js"
import {useOrderManagerStore} from "../../../store/modules/orderManager.js"
2026-02-10 16:39:04 +08:00
import MBCard from "../../../components/MB/MBCard.vue";
import MBPagination from "../../../components/MB/MBPagination.vue";
import MBLoading from "../../../components/MB/MBLoading.vue";
import ListItem from "./ListItem.vue";
import { getUserProfile } from "@/api/system/user"
const userType = ref()
2026-02-05 15:13:59 +08:00
const {proxy} = getCurrentInstance()
2025-08-28 17:29:25 +08:00
// 表单数据
2026-02-05 15:13:59 +08:00
const baseFormData = ref({})
2025-08-28 17:29:25 +08:00
//订单类型
2026-02-05 15:13:59 +08:00
const orderTypeList = ref([])
2025-08-28 17:29:25 +08:00
const paymentValue = ref(0)
const companyValue = ref(0)
2026-02-10 16:39:04 +08:00
// 添加加载状态
const loading = ref(true)
const total = ref(0)
2025-08-28 17:29:25 +08:00
const paging = ref({
// 页码
pageNum: 1,
// 分页数量
2026-02-10 17:28:08 +08:00
pageSize: 20,
2025-08-28 17:29:25 +08:00
isAsc: 'descending',
orderByColumn: 'adddate'
})
const queryParams = ref({
2026-02-05 15:13:59 +08:00
params: {
2025-08-28 17:29:25 +08:00
state: "0,1,-1,2,-2,3,-3,9,10,11,12,-12,13,-13,14,15,16",
}
})
2026-02-10 16:39:04 +08:00
2025-08-28 17:29:25 +08:00
const stateList = ref([])
const companyOptions = ref([])
2026-03-09 08:25:36 +08:00
const businessCompanyList = ref([])
2025-08-28 17:29:25 +08:00
// 合同数据
2026-02-10 16:39:04 +08:00
const tableData = ref([])
2025-08-28 17:29:25 +08:00
// 初始化数据
2026-02-10 16:39:04 +08:00
onMounted(async () => {
try {
loading.value = true
await getDictData()
await getDeptLists()
2026-03-09 08:25:36 +08:00
await getBussinessLists()
2026-02-10 16:39:04 +08:00
await getUser()
await getTableData()
} finally {
loading.value = false
}
2025-08-28 17:29:25 +08:00
})
2026-02-10 16:39:04 +08:00
function getUser() {
getUserProfile().then(response => {
userType.value = response.data.userType
})
}
2025-08-28 17:29:25 +08:00
// 格式化日期
function formatDate(dateString) {
2026-02-05 15:13:59 +08:00
if (!dateString) return '未知日期'
return dateString.split(' ')[0]
2025-08-28 17:29:25 +08:00
}
2026-02-05 15:13:59 +08:00
2025-08-28 17:29:25 +08:00
//获取字典数据
2026-02-10 16:39:04 +08:00
const getDictData = async () => {
try {
const [stateRes, typeRes] = await Promise.all([
getDicts("order_state"),
getDicts("dazhong_dingdan_type")
])
stateList.value = stateRes.data.map(item => {
2026-02-05 15:13:59 +08:00
return {
value: item.dictValue,
text: item.dictLabel
}
})
2026-02-10 16:39:04 +08:00
orderTypeList.value = typeRes.data
} catch (error) {
console.error('获取字典数据失败:', error)
}
2025-08-28 17:29:25 +08:00
}
2026-02-05 15:13:59 +08:00
2026-02-10 16:39:04 +08:00
//获取列表数据
const getTableData = async () => {
try {
loading.value = true
const data = await listsalemain(queryParams.value, paging.value)
total.value = data.total
tableData.value = data.rows
} catch (error) {
console.error('获取数据失败:', error)
} finally {
loading.value = false
}
2025-08-28 17:29:25 +08:00
}
2026-03-09 08:25:36 +08:00
// 获取货主
2026-02-10 16:39:04 +08:00
const getDeptLists = async () => {
try {
const res = await listproductList()
2026-02-05 15:13:59 +08:00
companyOptions.value = res.data.map(item => {
return {
value: item.deptId,
text: item.deptName
}
})
2026-02-10 16:39:04 +08:00
} catch (error) {
console.error('获取部门列表失败:', error)
}
2025-08-28 17:29:25 +08:00
}
2026-03-09 08:25:36 +08:00
// 获取所有商业公司
const getBussinessLists = async () => {
try {
const res = await getBusinessList({
isUnit: 0,
queryParam:{
areaId: 0,
}
})
businessCompanyList.value = res.data.map(item => {
return {
value: item.userid,
text: item.businessname
}
})
} catch (error) {
console.error('获取商业公司列表失败:', error)
}
}
// 添加一个新变量来存储选中的文本
const selectedCompanyText = ref('')
2026-02-05 15:13:59 +08:00
2026-03-09 08:25:36 +08:00
// 处理公司选择
const handleCompanySelect = (text) => {
selectedCompanyText.value = text
// 找到对应的公司ID
const company = businessCompanyList.value.find(item => item.text === text)
queryParams.value.userid = company ? company.value : ''
getTableData()
}
2025-08-28 17:29:25 +08:00
// 筛选合同
2026-02-10 16:39:04 +08:00
function filtertableData(e) {
2026-02-05 15:13:59 +08:00
console.log("筛选条件变化:", e)
// 计算属性会自动更新,无需额外操作
2025-08-28 17:29:25 +08:00
}
2026-02-05 15:13:59 +08:00
2025-08-28 17:29:25 +08:00
//编号输入框事件
2026-02-05 15:13:59 +08:00
const handleInput = (e) => {
console.log('handleInput', e.detail.value)
2025-08-28 17:29:25 +08:00
}
2026-02-05 15:13:59 +08:00
2025-08-28 17:29:25 +08:00
// 跳转到详情页
function gotoDetail(contract) {
2026-02-05 15:13:59 +08:00
console.log("查看合同详情:", contract)
//存储要传的值到pinia
useOrderManagerStore().addOrder(contract)
console.log('数据', useOrderManagerStore().orders)
if (contract.state == '0') {
uni.navigateTo({
url: "/pages/work/OrderManager/components/EditData?"
});
} else {
uni.navigateTo({
url: "/pages/work/OrderManager/components/LookData"
});
}
2025-08-28 17:29:25 +08:00
}
2026-02-05 15:13:59 +08:00
const gotoNewAdd = () => {
uni.navigateTo({
url: "/pages/work/OrderManager/components/NewAdd"
});
2025-08-28 17:29:25 +08:00
}
2026-02-10 16:39:04 +08:00
const handleQuery = async () => {
try {
loading.value = true
const data = await listsalemain(queryParams.value, paging.value)
total.value = data.total
tableData.value = data.rows
} catch (error) {
console.error('获取数据失败:', error)
} finally {
loading.value = false
}
}
2025-08-28 17:29:25 +08:00
</script>
<style lang="scss" scoped>
2026-02-10 16:39:04 +08:00
/* 加载动画容器 */
.loading-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 40px 0;
min-height: 300px;
}
.loading-text {
margin-top: 10px;
color: #666;
font-size: 14px;
}
2026-02-05 15:13:59 +08:00
.custom-input {
border: 1px solid #ccc;
border-radius: 4px;
padding: 5px;
height: 35px;
2026-02-10 16:39:04 +08:00
font-size: 12px;
2026-02-05 15:13:59 +08:00
}
2025-08-28 17:29:25 +08:00
.container {
2026-02-05 15:13:59 +08:00
padding: 10px;
background-color: #f5f7fa;
min-height: 100vh;
2025-08-28 17:29:25 +08:00
}
.example {
2026-02-05 15:13:59 +08:00
padding: 10px;
background: #fff;
border-radius: 8px;
margin-bottom: 15px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
2025-08-28 17:29:25 +08:00
}
:deep(.uni-section .uni-section-header) {
2026-02-05 15:13:59 +08:00
padding: 0;
2025-08-28 17:29:25 +08:00
}
:deep(.uni-card) {
2026-02-05 15:13:59 +08:00
padding: 0 !important;
margin: 10px 0 !important;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
2025-08-28 17:29:25 +08:00
}
:deep(.uni-card__content) {
2026-02-05 15:13:59 +08:00
padding: 12px !important;
2025-08-28 17:29:25 +08:00
}
.demo-uni-row {
2026-02-05 15:13:59 +08:00
padding: 5px 0;
font-size: 14px;
2025-08-28 17:29:25 +08:00
}
.demo-uni-col {
2026-02-05 15:13:59 +08:00
padding: 2px 0;
&.dark {
color: #333;
font-weight: 500;
}
&.light {
color: #666;
}
2025-08-28 17:29:25 +08:00
}
.card-even {
2026-02-05 15:13:59 +08:00
border-left: 4px solid #2979ff;
2025-08-28 17:29:25 +08:00
}
.card-odd {
2026-02-05 15:13:59 +08:00
border-left: 4px solid #19be6b;
2025-08-28 17:29:25 +08:00
}
.no-data {
2026-02-05 15:13:59 +08:00
text-align: center;
padding: 40px 0;
color: #999;
font-size: 16px;
2025-08-28 17:29:25 +08:00
}
2026-02-10 17:28:08 +08:00
uni-button{
font-size: 14px;
}
2025-08-28 17:29:25 +08:00
</style>