|
|
@@ -16,37 +16,99 @@
|
|
|
@add="handleAdd"
|
|
|
@pageHandleChange="pageHandleChange"
|
|
|
>
|
|
|
+ <template #status="{ item }">
|
|
|
+ <v-chip :color="getStatusColor(item.status)" small>{{ item.status_label }}</v-chip>
|
|
|
+ </template>
|
|
|
+ <template #can_connect="{ item }">
|
|
|
+ <v-icon v-if="item.can_connect === true" color="success" small>mdi-check-circle</v-icon>
|
|
|
+ <v-icon v-else-if="item.can_connect === false" color="error" small>mdi-close-circle</v-icon>
|
|
|
+ <span v-else>-</span>
|
|
|
+ </template>
|
|
|
+ <template #created_at="{ item }">
|
|
|
+ <span>{{ formatDateTime(item.created_at) }}</span>
|
|
|
+ </template>
|
|
|
<template #actions="{ item }">
|
|
|
- <v-btn text color="success" @click="handleEdit(item)">编辑</v-btn>
|
|
|
- <v-btn text color="error" @click="handleDelete(item)">删除</v-btn>
|
|
|
+ <v-btn text color="primary" @click="handleDetail(item)">详情</v-btn>
|
|
|
+ <v-btn v-if="item.status === 'processing'" text color="primary" @click="handleComplete(item)">完成</v-btn>
|
|
|
+ <v-btn v-if="item.status === 'pending'" text color="success" @click="handleAnalyze(item)">分析</v-btn>
|
|
|
+ <v-btn v-if="item.status === 'manual_review'" text color="success" @click="handleApprove(item)">审批</v-btn>
|
|
|
+ <v-btn v-if="item.status === 'manual_review'" text color="warning" @click="handleReject(item)">驳回</v-btn>
|
|
|
+ <v-btn v-if="canDelete(item.status)" text color="error" @click="handleDelete(item)">删除</v-btn>
|
|
|
</template>
|
|
|
</table-list>
|
|
|
+
|
|
|
+ <!-- 创建订单对话框 -->
|
|
|
+ <create-order-dialog :visible.sync="createDialog.show" @success="handleCreateSuccess" />
|
|
|
+
|
|
|
+ <!-- 订单详情对话框 -->
|
|
|
+ <order-detail-dialog
|
|
|
+ :visible.sync="detailDialog.show"
|
|
|
+ :order-id="detailDialog.orderId"
|
|
|
+ @refresh="init"
|
|
|
+ @analyze="handleAnalyzeFromDetail"
|
|
|
+ @approve="handleApproveFromDetail"
|
|
|
+ @reject="handleRejectFromDetail"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 驳回订单对话框 -->
|
|
|
+ <reject-order-dialog :visible.sync="rejectDialog.show" :order-id="rejectDialog.orderId" @success="init" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import MFilter from '@/components/Filter'
|
|
|
import TableList from '@/components/List/table'
|
|
|
+import CreateOrderDialog from './components/CreateOrderDialog'
|
|
|
+import OrderDetailDialog from './components/OrderDetailDialog'
|
|
|
+import RejectOrderDialog from './components/RejectOrderDialog'
|
|
|
+import { api } from '@/api/dataOrder'
|
|
|
+import { formatDate } from '@/utils/date'
|
|
|
|
|
|
export default {
|
|
|
name: 'dataOrder',
|
|
|
components: {
|
|
|
MFilter,
|
|
|
- TableList
|
|
|
+ TableList,
|
|
|
+ CreateOrderDialog,
|
|
|
+ OrderDetailDialog,
|
|
|
+ RejectOrderDialog
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
+ api,
|
|
|
loading: false,
|
|
|
filter: {
|
|
|
list: [
|
|
|
- { type: 'textField', value: '', label: '关键词', key: 'search', placeholder: '搜索订单信息' }
|
|
|
+ { type: 'textField', value: '', label: '关键词', key: 'search', placeholder: '搜索订单标题或描述' },
|
|
|
+ {
|
|
|
+ type: 'select',
|
|
|
+ value: null,
|
|
|
+ label: '状态',
|
|
|
+ key: 'status',
|
|
|
+ items: [
|
|
|
+ { label: '全部', value: null },
|
|
|
+ { label: '待处理', value: 'pending' },
|
|
|
+ { label: '分析中', value: 'analyzing' },
|
|
|
+ { label: '加工中', value: 'processing' },
|
|
|
+ { label: '已完成', value: 'completed' },
|
|
|
+ { label: '已驳回', value: 'rejected' },
|
|
|
+ { label: '待补充', value: 'need_supplement' },
|
|
|
+ { label: '待人工处理', value: 'manual_review' },
|
|
|
+ { label: '已更新', value: 'updated' }
|
|
|
+ ],
|
|
|
+ itemText: 'label',
|
|
|
+ itemValue: 'value'
|
|
|
+ }
|
|
|
]
|
|
|
},
|
|
|
headers: [
|
|
|
{ text: '订单编号', value: 'order_no' },
|
|
|
- { text: '订单名称', value: 'order_name' },
|
|
|
+ { text: '标题', value: 'title' },
|
|
|
+ { text: '状态', value: 'status' },
|
|
|
+ { text: '可连通', value: 'can_connect' },
|
|
|
+ { text: '创建人', value: 'created_by' },
|
|
|
{ text: '创建时间', value: 'created_at' },
|
|
|
- { text: '操作', value: 'actions', align: 'center' }
|
|
|
+ { text: '操作', value: 'actions' }
|
|
|
],
|
|
|
items: [],
|
|
|
total: 0,
|
|
|
@@ -54,7 +116,18 @@ export default {
|
|
|
size: 20,
|
|
|
current: 1
|
|
|
},
|
|
|
- query: {}
|
|
|
+ query: {},
|
|
|
+ createDialog: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ detailDialog: {
|
|
|
+ show: false,
|
|
|
+ orderId: null
|
|
|
+ },
|
|
|
+ rejectDialog: {
|
|
|
+ show: false,
|
|
|
+ orderId: null
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
@@ -75,12 +148,9 @@ export default {
|
|
|
delete params[key]
|
|
|
}
|
|
|
})
|
|
|
- // TODO: 调用数据订单API
|
|
|
- // const { data } = await api.getOrders(params)
|
|
|
- // this.total = data.pagination.total
|
|
|
- // this.items = data.list
|
|
|
- this.items = []
|
|
|
- this.total = 0
|
|
|
+ const { data } = await api.getOrders(params)
|
|
|
+ this.total = data.pagination.total
|
|
|
+ this.items = data.list
|
|
|
} catch (error) {
|
|
|
this.$snackbar.error(error)
|
|
|
} finally {
|
|
|
@@ -97,18 +167,54 @@ export default {
|
|
|
this.init()
|
|
|
},
|
|
|
handleAdd () {
|
|
|
- // TODO: 新增订单
|
|
|
- this.$snackbar.info('功能开发中')
|
|
|
+ this.createDialog.show = true
|
|
|
+ },
|
|
|
+ // 订单详情
|
|
|
+ handleDetail (item) {
|
|
|
+ this.detailDialog.orderId = item.id
|
|
|
+ this.detailDialog.show = true
|
|
|
+ },
|
|
|
+ // 分析订单
|
|
|
+ async handleAnalyze (item) {
|
|
|
+ const analyzingItem = item
|
|
|
+ analyzingItem.analyzing = true
|
|
|
+ try {
|
|
|
+ const { data } = await api.analyzeOrder(item.id)
|
|
|
+ if (data.can_connect) {
|
|
|
+ this.$snackbar.success('分析完成,实体可连通!')
|
|
|
+ } else {
|
|
|
+ this.$snackbar.warning('分析完成,部分实体无法连通')
|
|
|
+ }
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ } finally {
|
|
|
+ analyzingItem.analyzing = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 审批订单
|
|
|
+ async handleApprove (item) {
|
|
|
+ try {
|
|
|
+ await this.$confirm('审批确认', `确定要审批通过订单 "${item.title}" 吗?`)
|
|
|
+ await api.approveOrder(item.id)
|
|
|
+ this.$snackbar.success('审批通过')
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
- handleEdit (item) {
|
|
|
- // TODO: 编辑订单
|
|
|
- this.$snackbar.info('功能开发中')
|
|
|
+ // 驳回订单
|
|
|
+ handleReject (item) {
|
|
|
+ this.rejectDialog.orderId = item.id
|
|
|
+ this.rejectDialog.show = true
|
|
|
},
|
|
|
+ // 删除订单
|
|
|
async handleDelete (item) {
|
|
|
try {
|
|
|
- await this.$confirm('删除确认', '确定要删除该订单吗?此操作不可恢复。')
|
|
|
- // TODO: 调用删除API
|
|
|
- // await api.deleteOrder(item.id)
|
|
|
+ await this.$confirm('删除确认', `确定要删除订单 "${item.title}" 吗?此操作不可恢复。`)
|
|
|
+ await api.deleteOrder(item.id)
|
|
|
this.$snackbar.success('删除成功')
|
|
|
this.init()
|
|
|
} catch (error) {
|
|
|
@@ -116,6 +222,66 @@ export default {
|
|
|
this.$snackbar.error(error)
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ // 创建订单成功
|
|
|
+ handleCreateSuccess () {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ // 分析订单
|
|
|
+ handleAnalyzeFromDetail (orderId) {
|
|
|
+ const item = this.items.find(i => i.id === orderId)
|
|
|
+ if (item) {
|
|
|
+ this.handleAnalyze(item)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 审批订单
|
|
|
+ handleApproveFromDetail (orderId) {
|
|
|
+ const item = this.items.find(i => i.id === orderId)
|
|
|
+ if (item) {
|
|
|
+ this.handleApprove(item)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 驳回订单
|
|
|
+ handleRejectFromDetail (orderId) {
|
|
|
+ const item = this.items.find(i => i.id === orderId)
|
|
|
+ if (item) {
|
|
|
+ this.handleReject(item)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 完成订单
|
|
|
+ async handleComplete (item) {
|
|
|
+ try {
|
|
|
+ await api.completeOrder(item.id, {
|
|
|
+ productId: item.result_product_id,
|
|
|
+ dataflowId: item.result_dataflow_id,
|
|
|
+ processedBy: item.created_by
|
|
|
+ })
|
|
|
+ this.$snackbar.success('操作成功')
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getStatusColor (status) {
|
|
|
+ const colors = {
|
|
|
+ pending: 'info',
|
|
|
+ analyzing: 'warning',
|
|
|
+ processing: 'primary',
|
|
|
+ completed: 'success',
|
|
|
+ rejected: 'error',
|
|
|
+ need_supplement: 'warning',
|
|
|
+ manual_review: 'warning',
|
|
|
+ updated: 'info'
|
|
|
+ }
|
|
|
+ return colors[status] || 'info'
|
|
|
+ },
|
|
|
+ canDelete (status) {
|
|
|
+ return ['pending', 'completed', 'rejected'].includes(status)
|
|
|
+ },
|
|
|
+ formatDateTime (dateStr) {
|
|
|
+ return formatDate(dateStr)
|
|
|
}
|
|
|
}
|
|
|
}
|