|
|
@@ -29,36 +29,59 @@
|
|
|
</template>
|
|
|
<template #actions="{ item }">
|
|
|
<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="canEdit(item.status)"
|
|
|
+ text
|
|
|
+ color="primary"
|
|
|
+ @click="handleAdd(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" />
|
|
|
+ <!-- 创建、编辑订单对话框 -->
|
|
|
+ <edit-dialog
|
|
|
+ :visible.sync="createDialog.show"
|
|
|
+ :title="createDialog.itemData.id ? '编辑数据订单' : '创建数据订单'"
|
|
|
+ :footer="true"
|
|
|
+ @submit="handleCreateSuccess"
|
|
|
+ @close="handleCloseCreateDialog"
|
|
|
+ >
|
|
|
+ <OrderForm v-if="createDialog.show" ref="editFormRef" :item-data="createDialog.itemData" />
|
|
|
+ </edit-dialog>
|
|
|
|
|
|
<!-- 订单详情对话框 -->
|
|
|
- <order-detail-dialog
|
|
|
+ <edit-dialog
|
|
|
:visible.sync="detailDialog.show"
|
|
|
- :order-id="detailDialog.orderId"
|
|
|
- @refresh="init"
|
|
|
- @analyze="handleAnalyzeFromDetail"
|
|
|
- @approve="handleApproveFromDetail"
|
|
|
- @reject="handleRejectFromDetail"
|
|
|
- />
|
|
|
+ title="订单详情"
|
|
|
+ :footer="false"
|
|
|
+ @close="detailDialog.show = false"
|
|
|
+ >
|
|
|
+ <OrderDetailDialog
|
|
|
+ v-if="detailDialog.show"
|
|
|
+ :order-id="detailDialog.orderId"
|
|
|
+ @refresh="init"
|
|
|
+ @reject="handleRejectFromDetail"
|
|
|
+ @close="detailDialog.show = false"
|
|
|
+ />
|
|
|
+ </edit-dialog>
|
|
|
|
|
|
<!-- 驳回订单对话框 -->
|
|
|
- <reject-order-dialog :visible.sync="rejectDialog.show" :order-id="rejectDialog.orderId" @success="init" />
|
|
|
+ <reject-order-dialog
|
|
|
+ :visible.sync="rejectDialog.show"
|
|
|
+ :order-id="rejectDialog.orderId"
|
|
|
+ @success="handleRejectSuccess"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import EditDialog from '@/components/Dialog'
|
|
|
import MFilter from '@/components/Filter'
|
|
|
import TableList from '@/components/List/table'
|
|
|
-import CreateOrderDialog from './components/CreateOrderDialog'
|
|
|
+import OrderForm from './components/OrderForm'
|
|
|
import OrderDetailDialog from './components/OrderDetailDialog'
|
|
|
import RejectOrderDialog from './components/RejectOrderDialog'
|
|
|
import { api } from '@/api/dataOrder'
|
|
|
@@ -69,9 +92,10 @@ export default {
|
|
|
components: {
|
|
|
MFilter,
|
|
|
TableList,
|
|
|
- CreateOrderDialog,
|
|
|
+ OrderForm,
|
|
|
OrderDetailDialog,
|
|
|
- RejectOrderDialog
|
|
|
+ RejectOrderDialog,
|
|
|
+ EditDialog
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
@@ -89,12 +113,13 @@ export default {
|
|
|
{ label: '全部', value: null },
|
|
|
{ label: '待处理', value: 'pending' },
|
|
|
{ label: '分析中', value: 'analyzing' },
|
|
|
+ { label: '待审批', value: 'pending_approval' },
|
|
|
{ label: '加工中', value: 'processing' },
|
|
|
+ { label: '数据产品就绪', value: 'onboard' },
|
|
|
{ label: '已完成', value: 'completed' },
|
|
|
{ label: '已驳回', value: 'rejected' },
|
|
|
{ label: '待补充', value: 'need_supplement' },
|
|
|
- { label: '待人工处理', value: 'manual_review' },
|
|
|
- { label: '已更新', value: 'updated' }
|
|
|
+ { label: '待人工处理', value: 'manual_review' }
|
|
|
],
|
|
|
itemText: 'label',
|
|
|
itemValue: 'value'
|
|
|
@@ -118,7 +143,8 @@ export default {
|
|
|
},
|
|
|
query: {},
|
|
|
createDialog: {
|
|
|
- show: false
|
|
|
+ show: false,
|
|
|
+ itemData: {}
|
|
|
},
|
|
|
detailDialog: {
|
|
|
show: false,
|
|
|
@@ -166,9 +192,6 @@ export default {
|
|
|
this.pageInfo.current = index
|
|
|
this.init()
|
|
|
},
|
|
|
- handleAdd () {
|
|
|
- this.createDialog.show = true
|
|
|
- },
|
|
|
// 订单详情
|
|
|
handleDetail (item) {
|
|
|
this.detailDialog.orderId = item.id
|
|
|
@@ -176,8 +199,6 @@ export default {
|
|
|
},
|
|
|
// 分析订单
|
|
|
async handleAnalyze (item) {
|
|
|
- const analyzingItem = item
|
|
|
- analyzingItem.analyzing = true
|
|
|
try {
|
|
|
const { data } = await api.analyzeOrder(item.id)
|
|
|
if (data.can_connect) {
|
|
|
@@ -185,31 +206,34 @@ export default {
|
|
|
} else {
|
|
|
this.$snackbar.warning('分析完成,部分实体无法连通')
|
|
|
}
|
|
|
+ this.detailDialog.show = false
|
|
|
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)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+ // async handleApprove (item) {
|
|
|
+ // try {
|
|
|
+ // await api.approveOrder(item.id)
|
|
|
+ // this.$snackbar.success('审批通过')
|
|
|
+ // this.detailDialog.show = false
|
|
|
+ // this.init()
|
|
|
+ // } catch (error) {
|
|
|
+ // if (error !== 'cancel') {
|
|
|
+ // this.$snackbar.error(error)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
// 驳回订单
|
|
|
handleReject (item) {
|
|
|
this.rejectDialog.orderId = item.id
|
|
|
this.rejectDialog.show = true
|
|
|
},
|
|
|
+ handleRejectSuccess () {
|
|
|
+ this.init()
|
|
|
+ this.detailDialog.show = false
|
|
|
+ },
|
|
|
// 删除订单
|
|
|
async handleDelete (item) {
|
|
|
try {
|
|
|
@@ -223,24 +247,45 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- // 创建订单成功
|
|
|
- handleCreateSuccess () {
|
|
|
- this.init()
|
|
|
- },
|
|
|
- // 分析订单
|
|
|
- handleAnalyzeFromDetail (orderId) {
|
|
|
- const item = this.items.find(i => i.id === orderId)
|
|
|
- if (item) {
|
|
|
- this.handleAnalyze(item)
|
|
|
+ // 创建、编辑订单
|
|
|
+ async handleCreateSuccess () {
|
|
|
+ const params = this.$refs.editFormRef.getValue()
|
|
|
+ if (!params) {
|
|
|
+ this.$snackbar.warning('请填写完整订单信息')
|
|
|
+ return
|
|
|
}
|
|
|
- },
|
|
|
- // 审批订单
|
|
|
- handleApproveFromDetail (orderId) {
|
|
|
- const item = this.items.find(i => i.id === orderId)
|
|
|
- if (item) {
|
|
|
- this.handleApprove(item)
|
|
|
+ try {
|
|
|
+ if (this.createDialog.itemData.id) {
|
|
|
+ await api.updateOrder(this.createDialog.itemData.id, params)
|
|
|
+ this.$snackbar.success('订单更新成功')
|
|
|
+ } else {
|
|
|
+ await api.createOrder(params)
|
|
|
+ this.$snackbar.success('订单创建成功')
|
|
|
+ }
|
|
|
+ this.handleCloseCreateDialog()
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
}
|
|
|
},
|
|
|
+ handleCloseCreateDialog () {
|
|
|
+ this.createDialog.show = false
|
|
|
+ this.createDialog.itemData = {}
|
|
|
+ },
|
|
|
+ // 分析订单
|
|
|
+ // 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)
|
|
|
@@ -249,34 +294,46 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 完成订单
|
|
|
- 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)
|
|
|
- }
|
|
|
- }
|
|
|
+ // handleCompleteFromDetail (orderId) {
|
|
|
+ // const item = this.items.find(i => i.id === orderId)
|
|
|
+ // if (item) {
|
|
|
+ // this.handleComplete(item)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ handleAdd (item = {}) {
|
|
|
+ this.createDialog.show = true
|
|
|
+ this.createDialog.itemData = item
|
|
|
},
|
|
|
+ // 完成订单
|
|
|
+ // async handleComplete (item) {
|
|
|
+ // try {
|
|
|
+ // await api.completeOrder(item.id)
|
|
|
+ // this.$snackbar.success('订单已完成')
|
|
|
+ // this.init()
|
|
|
+ // } catch (error) {
|
|
|
+ // if (error !== 'cancel') {
|
|
|
+ // this.$snackbar.error(error)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
getStatusColor (status) {
|
|
|
const colors = {
|
|
|
pending: 'info',
|
|
|
analyzing: 'warning',
|
|
|
+ pending_approval: 'primary',
|
|
|
processing: 'primary',
|
|
|
+ onboard: 'success',
|
|
|
completed: 'success',
|
|
|
rejected: 'error',
|
|
|
need_supplement: 'warning',
|
|
|
- manual_review: 'warning',
|
|
|
- updated: 'info'
|
|
|
+ manual_review: 'warning'
|
|
|
}
|
|
|
return colors[status] || 'info'
|
|
|
},
|
|
|
+ // 状态判断函数
|
|
|
+ canEdit (status) {
|
|
|
+ return ['pending', 'manual_review', 'need_supplement'].includes(status)
|
|
|
+ },
|
|
|
canDelete (status) {
|
|
|
return ['pending', 'completed', 'rejected'].includes(status)
|
|
|
},
|