|
@@ -3,11 +3,11 @@
|
|
|
<div class="flex justify-between">
|
|
|
<div class="title">相关销售订单</div>
|
|
|
<div>
|
|
|
- <el-button type="primary">新建销售订单</el-button>
|
|
|
+ <el-button type="primary" @click="editOrder()">新建销售订单</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="flex-1 overflow-auto pt-3">
|
|
|
- <el-table :data="relatedTaskstable" border style="width: 100%;height: 300px;">
|
|
|
+ <el-table :data="relatedOrders" border style="width: 100%;height: 300px;">
|
|
|
<el-table-column prop="priority" label="订单编号" width="130" />
|
|
|
<el-table-column prop="taskName" label="订单名称">
|
|
|
<template #default="scope">
|
|
@@ -27,56 +27,162 @@
|
|
|
<el-table-column prop="endTime" label="创建时间" width="130" />
|
|
|
</el-table>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 弹窗 -->
|
|
|
+ <el-dialog v-model="allVisible.editOrderVisible" width="1000" :show-close="false" top="10vh">
|
|
|
+ <template #header="{ close, titleId, titleClass }">
|
|
|
+ <div class="flex justify-between items-center border-b pb-3 dialog-header">
|
|
|
+ <h4 :id="titleId">{{ '新建销售订单' }}</h4>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" :loading="allLoading.editSaveLading"
|
|
|
+ @click="saveOrder(false)">保存</el-button>
|
|
|
+ <el-button @click="closeVisible('editOrderVisible')">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.orderTemplateLoadinng">
|
|
|
+ <GenerateForm ref="orderTemplateRef" :data="orderTemplate" :key="orderTemplateKey"
|
|
|
+ :value="orderTemplateValue" />
|
|
|
+ <div>相关产品</div>
|
|
|
+ <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
|
|
|
+ :productTableListValue="productTableListValue" />
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, reactive, onMounted, onUnmounted, defineExpose, inject } from 'vue'
|
|
|
+import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
|
|
|
+import { setTemplateDataDisable } from '@/utils/tools';
|
|
|
+import { GenerateForm } from '@zmjs/form-design';
|
|
|
+import { get, post } from '@/utils/request';
|
|
|
+
|
|
|
+import RelatedProducts from '@/components/relatedProducts/relatedProducts.vue'
|
|
|
+import { GETGENERATEFOEM, GETTABLELIST, URL_OEDERUPDATE } from '@/pages/order/api';
|
|
|
+import { formatDate } from '@/utils/times';
|
|
|
+
|
|
|
+const emits = defineEmits(['refreshData']);
|
|
|
+const globalPopup = inject<GlobalPopup>('globalPopup')
|
|
|
+const props = defineProps<{
|
|
|
+ data: any
|
|
|
+}>()
|
|
|
+
|
|
|
+const information = ref<any>({})
|
|
|
+const relatedOrders = ref([])
|
|
|
+const productTableList = ref([])
|
|
|
+const productTableListValue = ref([])
|
|
|
+const orderTemplateValue = ref({})
|
|
|
+const orderTemplateKey = ref(1)
|
|
|
+const orderTemplateRef = ref<typeof GenerateForm>()
|
|
|
+const relatedProductsRef = ref<typeof RelatedProducts>()
|
|
|
+const orderTemplate = ref({
|
|
|
+ list: [],
|
|
|
+ config: {}
|
|
|
+})
|
|
|
+const allVisible = reactive({
|
|
|
+ editOrderVisible: false,
|
|
|
+})
|
|
|
+const allLoading = reactive({
|
|
|
+ editSaveLading: false,
|
|
|
+ orderTemplateLoadinng: false,
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function saveOrder(flag: boolean) {
|
|
|
+ orderTemplateRef.value?.getData().then((res: any) => {
|
|
|
+ let productTableListData = relatedProductsRef?.value?.returnData()
|
|
|
+ for (var i in productTableListData) {
|
|
|
+ productTableListData[i].sealPrice = productTableListData[i].sellingPrice,
|
|
|
+ productTableListData[i].discount = productTableListData[i].discount,
|
|
|
+ productTableListData[i].num = productTableListData[i].quantity
|
|
|
+ }
|
|
|
+ const produt = productTableListData ? JSON.stringify(productTableListData) : []
|
|
|
+ allLoading.editSaveLading = true
|
|
|
+ post(URL_OEDERUPDATE, {
|
|
|
+ ...orderTemplateValue.value,
|
|
|
+ ...res,
|
|
|
+ orderEndDate: res.orderEndDate ? formatDate(res.orderEndDate) : '',
|
|
|
+ orderStartDate: res.orderStartDate ? formatDate(res.orderStartDate) : '',
|
|
|
+ orderProductDetailString: produt
|
|
|
+ }).then((_res) => {
|
|
|
+ allVisible.editOrderVisible = flag
|
|
|
+ globalPopup?.showSuccess('操作成功')
|
|
|
+ if (flag) {
|
|
|
+ orderTemplateRef.value?.reset()
|
|
|
+ }
|
|
|
+ emits('refreshData')
|
|
|
+ }).finally(() => {
|
|
|
+ allLoading.editSaveLading = false
|
|
|
+ })
|
|
|
+ }).catch((_err: any) => {
|
|
|
+ globalPopup?.showError('请填写完整')
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function editOrder() {
|
|
|
+ showVisible('editOrderVisible')
|
|
|
+ allLoading.orderTemplateLoadinng = true
|
|
|
+
|
|
|
+ orderTemplateValue.value = { customId: information.value.id }
|
|
|
+ productTableListValue.value = []
|
|
|
+ setTimeout(() => {
|
|
|
+ orderTemplateRef.value && orderTemplateRef.value.reset()
|
|
|
+ orderTemplateKey.value++
|
|
|
+ allLoading.orderTemplateLoadinng = false
|
|
|
+ }, 1000)
|
|
|
+}
|
|
|
+
|
|
|
+async function getSystemField() {
|
|
|
+ const datas = await get(GETGENERATEFOEM)
|
|
|
+ let newConfig = JSON.parse(datas.data[0].config)
|
|
|
+ newConfig.list = setTemplateDataDisable(newConfig.list, ['customId'])
|
|
|
+ orderTemplate.value = newConfig
|
|
|
+}
|
|
|
+
|
|
|
+function showVisible(type: keyof typeof allVisible) {
|
|
|
+ allVisible[type] = true
|
|
|
+}
|
|
|
+
|
|
|
+function closeVisible(type: keyof typeof allVisible) {
|
|
|
+ allVisible[type] = false
|
|
|
+}
|
|
|
+
|
|
|
+function getProductTableList() {
|
|
|
+ post(GETTABLELIST, { pageIndex: -1, pageSize: -1 }).then((res) => {
|
|
|
+ if (res.code == 'ok') {
|
|
|
+ const { record, total } = res.data
|
|
|
+ productTableList.value = record.map((item: any) => {
|
|
|
+ const { id, productName, productCode, unit, unitName, typeName, type, price, inventory } = item
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ productId: id,
|
|
|
+ productName,
|
|
|
+ productCode,
|
|
|
+ unit,
|
|
|
+ unitName,
|
|
|
+ price,
|
|
|
+ type,
|
|
|
+ typeName,
|
|
|
+ inventory,
|
|
|
+ quantity: '',
|
|
|
+ discount: '',
|
|
|
+ totalPrice: ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+watchEffect(() => {
|
|
|
+ const { data } = props
|
|
|
+ information.value = data
|
|
|
+ relatedOrders.value = []
|
|
|
+})
|
|
|
|
|
|
-const relatedTaskstable = ref([{
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}, {
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}, {
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}, {
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}, {
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}, {
|
|
|
- taskName: '任务名称20240316-tempalsbls',
|
|
|
- priority: '中',
|
|
|
- status: '进行中',
|
|
|
- executor: '张三',
|
|
|
- startTime: '2024-04-01',
|
|
|
- endTime: '2024-04-01',
|
|
|
-}])
|
|
|
// 生命周期钩子
|
|
|
onMounted(() => {
|
|
|
+ getProductTableList()
|
|
|
+ getSystemField()
|
|
|
});
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|