|
@@ -44,6 +44,16 @@
|
|
|
新增订单
|
|
|
</el-button>
|
|
|
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-refresh"
|
|
|
+ @click="handleSyncData"
|
|
|
+ :loading="syncLoading"
|
|
|
+ style="margin-left: 8px;"
|
|
|
+ >
|
|
|
+ 同步数据
|
|
|
+ </el-button>
|
|
|
+
|
|
|
</template>
|
|
|
|
|
|
<!-- 订单类型显示 -->
|
|
@@ -106,6 +116,7 @@
|
|
|
import { option } from './option'
|
|
|
import { getList, add, update, getDetail } from '@/api/order/order'
|
|
|
import { submitOrderToU9 } from '@/api/order/sales-order'
|
|
|
+import { getUnification } from '@/api/common'
|
|
|
import {
|
|
|
ORDER_TYPES,
|
|
|
ORDER_STATUS,
|
|
@@ -142,6 +153,8 @@ export default {
|
|
|
orderFormVisible: false,
|
|
|
isEditMode: false,
|
|
|
editOrderId: null,
|
|
|
+ // 同步按钮loading状态
|
|
|
+ syncLoading: false,
|
|
|
|
|
|
// 事件常量
|
|
|
ORDER_FORM_EVENTS
|
|
@@ -310,6 +323,32 @@ export default {
|
|
|
this.orderFormVisible = true
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 同步数据(调用通用unification接口)
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async handleSyncData() {
|
|
|
+ this.syncLoading = true
|
|
|
+ try {
|
|
|
+ const res = await getUnification()
|
|
|
+ const success = res && res.data && res.data.success
|
|
|
+ const msg = (res && res.data && (res.data.msg || res.data.message)) || (success ? '同步成功' : '同步失败')
|
|
|
+ if (success) {
|
|
|
+ this.$message.success(msg)
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ // 若拦截器对非正常code抛错,或网络异常
|
|
|
+ const msg = (error && error.response && error.response.data && (error.response.data.msg || error.response.data.message)) || (error && error.message) || '请求失败'
|
|
|
+ this.$message.error(msg)
|
|
|
+ // 控制台记录方便排查
|
|
|
+ console.error('同步数据失败:', error)
|
|
|
+ } finally {
|
|
|
+ this.syncLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|