From 3aedad63dd01f1fc5154cb520af32edab967d6e0 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周一, 12 5月 2025 09:15:26 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo

---
 PipeLineLems/pipelinelems_web/src/widgets/OrderManagement-main/views/order-management/index.vue | 1231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,231 insertions(+), 0 deletions(-)

diff --git a/PipeLineLems/pipelinelems_web/src/widgets/OrderManagement-main/views/order-management/index.vue b/PipeLineLems/pipelinelems_web/src/widgets/OrderManagement-main/views/order-management/index.vue
new file mode 100644
index 0000000..a0241a9
--- /dev/null
+++ b/PipeLineLems/pipelinelems_web/src/widgets/OrderManagement-main/views/order-management/index.vue
@@ -0,0 +1,1231 @@
+<!-- 鍒濇杩唬鏃堕棿锛�2023骞�4鏈堬紝tanzhiliang -->
+<template>
+  <div class="container light-element-ui">
+    <div class="header-status" v-if="!controlMode">
+      <div>{{ _t('鐢熶骇鐘舵��') }}</div>
+      <div class="status">{{ productionStatus }}</div>
+      <el-button
+        style="width: 80px"
+        size="small"
+        color="#03b982"
+        @click="() => onEmitAction(1)"
+        >{{ _t('寮�濮�') }}</el-button
+      >
+      <el-button
+        style="width: 80px; color: #fff"
+        color="#e57a74"
+        size="small"
+        @click="() => onEmitAction(0)"
+        >{{ _t('鍋滄') }}</el-button
+      >
+    </div>
+    <div class="head">
+      <div class="head-left">
+        <IconButton icon="add-p" @click="onAdd" type="primary">
+          {{ _t('鏂板缓宸ュ崟') }}
+        </IconButton>
+
+        <TableFilter
+          :text="_t('娣诲姞鏉′欢')"
+          :formData="ProductModel"
+          @data="updateFn"
+          :columns="columnsFilter"
+        >
+          <IconButton icon="f">{{ _t('绛涢��') }}</IconButton>
+        </TableFilter>
+
+        <IconButton icon="export" :onClick="onExport">
+          {{ _t('瀵煎嚭') }}
+        </IconButton>
+      </div>
+      <div class="head-right">
+        {{ _t('鏃堕棿鑼冨洿锛�') }}
+        <DatePicker
+          v-model="timeRange"
+          type="datetimerange"
+          range-separator="-"
+          :start-placeholder="_t('寮�濮嬫椂闂�')"
+          :end-placeholder="_t('缁撴潫鏃堕棿')"
+          value-format="YYYY-MM-DD HH:mm:ss"
+          :default-time="[
+            new Date(2000, 1, 1, 0, 0, 0),
+            new Date(2000, 2, 1, 23, 59, 59),
+          ]"
+          @change="onChangeDate"
+        />
+        <Search
+          v-model="condition.Filter"
+          @Confirm="initAllTableData"
+          :placeholder="_t('璇疯緭鍏ユ悳绱�')"
+          :style="{ marginLeft: '5px' }"
+        />
+      </div>
+    </div>
+    <template v-for="item in collapseList" :key="collapseOptions[item].key">
+      <CollapseTable
+        ref="colRef"
+        :table-head="currentTableHead(collapseOptions[item].key)"
+        v-model="collapseOptions[item].tableData"
+        v-bind="collapseOptions[item].attrsProp"
+        :status="collapseOptions[item].key"
+        :isStartFlushList="
+          [1, 0].includes(collapseOptions[item].key) ? isStartFlushList : false
+        "
+        initAllTableData
+        @emitSegment="onEmitSegment"
+        @onAction="onActions"
+        @Page="onPage"
+      />
+    </template>
+
+    <TipPop
+      v-if="tipParams.tipVisible"
+      :tipText="tipParams.tipText"
+      :tipTextIcon="tipParams.tipTextIcon"
+      :noCancel="tipParams.noCancel"
+      @tipCallBack="tipConfirm"
+    />
+    <ProductFormDialog
+      v-if="dialogVisible"
+      v-model="dialogVisible"
+      :dialogConfig="dialogConfig"
+      :status="dialogStatus"
+      @callback="callback"
+    />
+    <ModuleDialog
+      v-if="moduleDialogVisible"
+      v-model="moduleDialogVisible"
+      :moduleDialogConfig="moduleDialogConfig"
+      :onClearTable="onClearTable"
+      @close="onCloseDialog"
+    />
+    <PrepareFormDialog
+      v-if="prepareFormVisible"
+      v-model="prepareFormVisible"
+      :dialogConfig="prepareDialogConfig"
+      @callback="prepareCallback"
+    />
+    <SegmentDialog
+      :id="segmentConfig.row?.id"
+      v-model="segmentConfig.visible"
+      @confirm="onDeliverThen"
+    />
+  </div>
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  ref,
+  reactive,
+  computed,
+  PropType,
+  onMounted,
+  watch,
+  nextTick,
+  onUnmounted,
+} from 'vue'
+import get from 'lodash/get'
+import head from 'lodash/head'
+import isNull from 'lodash/isNull'
+import cloneDeep from 'lodash/cloneDeep'
+import { useGlobalState } from '@/libs/Store/Store'
+import { getSegments, getSegmentsList } from '../../api/process'
+
+import dayjs from 'dayjs'
+import api from '../../api/product-setting'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import type {
+  IProductTableItem,
+  IProductParamsRequest,
+} from '../../api/product'
+import { getEnum } from '../../enum'
+import CustomFormItem from '../../components/customFormItem/index.vue'
+import ProductFormDialog from '../../dialog/productForm.vue'
+import PrepareFormDialog from '../../dialog/prepareForm.vue'
+import Pagination from '../../components/pagination/index.vue'
+import TipPop from '../../components/TipPop/index.vue'
+import StatusComponent from '../../components/status/index.vue'
+import ModuleDialog from '../../dialog/moduleDialog/index.vue'
+import CollapseTable from '../../components/collapse-table/index.vue'
+import IconButton from '@/components/IconButton/IconButton'
+import Search from '@/components/Search/Search'
+import DatePicker from '@/components/DatePicker/index.vue'
+import TableFilter from '@/components/TableFilter/TableFilter'
+import { createInjector } from '../../hooks/use-permission'
+import SegmentDialog from '../../dialog/segment/segment'
+import { _t } from '../../app'
+import { Language } from '@/libs/Language/Language'
+import { useHook } from '@/libs/Hook/Hook'
+import { orderSegMap } from '../../state'
+import { Socket } from '@/libs/Socket'
+//import { downloadFile } from '@/utils/client'
+const { DIALOG_STATUS, ORDER_STATUS, ORDER_STATUS_MAP, ORDER_ACTIONS_STATUS } =
+  getEnum()
+
+export default defineComponent({
+  name: 'OrderManagement',
+  components: {
+    SegmentDialog,
+    ProductFormDialog,
+    PrepareFormDialog,
+    Pagination,
+    TipPop,
+    StatusComponent,
+    ModuleDialog,
+    CollapseTable,
+    CustomFormItem,
+    IconButton,
+    Search,
+    DatePicker,
+    TableFilter,
+  },
+  setup(props, { emit }) {
+    let t
+    const { VariableStore, Variable } = useHook(props, emit)
+    const { curTab } = createInjector()
+    watch(curTab, (val: any) => {
+      if (val == 'OrderManagement') {
+        initProdCode()
+      }
+    })
+
+    const segmentConfig = ref<{
+      visible: boolean
+      row: {
+        id?: string
+        tableSelectList?: any[]
+      }
+    }>({
+      visible: false,
+      row: {},
+    })
+    const colRef = ref()
+    const ProductModel = ref<Record<string, any>>({})
+    const prodCodeList = ref<any[]>([])
+    const isStartFlushList = ref(false)
+    const columnsFilter = computed<any[]>(() => [
+      {
+        field: 'ProductModel',
+        title: _t('浜у搧鍨嬪彿'),
+        el: 'select',
+        // 鎼滅储鏃舵墍鐢ㄧ殑瀛楁
+        prop: 'ProductModel',
+        options: prodCodeList,
+        placeholder: _t('璇烽�夋嫨'),
+      },
+    ])
+
+    const { isHasPermission } = createInjector()
+    // const timeRange: any = ref([
+    //   dayjs().subtract(7, 'day').startOf('day').format('YYYY-MM-DD 00:00:00'),
+    //   dayjs().startOf('day').format('YYYY-MM-DD 23:59:59'),
+    // ])
+    const timeRange: any = ref(['', '']) //bug-15153 榛樿鍘绘帀鏃堕棿鑼冨洿闄愬埗锛屽睍绀哄叏閲忔暟鎹�
+    const condition = ref({
+      Filter: '',
+      Status: '',
+      currentPage: 1,
+      pageSize: 10,
+      page: {},
+    })
+    const collapseOptions = ref({
+      [ORDER_STATUS.PRODUCTION]: {
+        // 鐢熶骇涓�
+        key: ORDER_STATUS.PRODUCTION,
+        tableData: [],
+        attrsProp: {
+          title: ORDER_STATUS_MAP[ORDER_STATUS.PRODUCTION],
+          total: 0,
+          hiddenSort: true,
+          buttons: [
+            ORDER_ACTIONS_STATUS.PAUSE,
+            ORDER_ACTIONS_STATUS.COMPLTE,
+            ORDER_ACTIONS_STATUS.FINISHED,
+          ],
+        },
+        sort: 0,
+      },
+      [ORDER_STATUS.PRODUCED]: {
+        // 寰呯敓浜�
+        key: ORDER_STATUS.PRODUCED,
+        tableData: [],
+        attrsProp: {
+          title: ORDER_STATUS_MAP[ORDER_STATUS.PRODUCED],
+          total: 0,
+          buttons: [
+            ORDER_ACTIONS_STATUS.DELIVER,
+            ORDER_ACTIONS_STATUS.PAUSE,
+            ORDER_ACTIONS_STATUS.FINISHED,
+          ],
+        },
+        sort: 1,
+      },
+      [ORDER_STATUS.PAUSED]: {
+        // 宸叉殏鍋�
+        key: ORDER_STATUS.PAUSED,
+        tableData: [],
+        attrsProp: {
+          title: ORDER_STATUS_MAP[ORDER_STATUS.PAUSED],
+          total: 0,
+          buttons: [
+            ORDER_ACTIONS_STATUS.ACTIVATION,
+            ORDER_ACTIONS_STATUS.FINISHED,
+            ORDER_ACTIONS_STATUS.EDIT,
+          ],
+        },
+        sort: 2,
+      },
+      [ORDER_STATUS.NOT_ACTIVE]: {
+        // 鏈縺娲�
+        key: ORDER_STATUS.NOT_ACTIVE,
+        tableData: [],
+        attrsProp: {
+          title: ORDER_STATUS_MAP[ORDER_STATUS.NOT_ACTIVE],
+          total: 0,
+          buttons: [
+            ORDER_ACTIONS_STATUS.ACTIVATION,
+            ORDER_ACTIONS_STATUS.EDIT,
+            ORDER_ACTIONS_STATUS.FINISHED,
+            ORDER_ACTIONS_STATUS.DELETE,
+            ORDER_ACTIONS_STATUS.UPLOAD,
+            ORDER_ACTIONS_STATUS.DOWNLOADTEMPLATE,
+          ],
+        },
+        sort: 3,
+      },
+    })
+    const collapseList = computed(() =>
+      Object.keys(collapseOptions.value).sort((a, b) => {
+        return collapseOptions.value[a].sort - collapseOptions.value[b].sort
+      })
+    )
+
+    const dialogVisible = ref(false)
+    const dialogConfig = ref<IProductParamsRequest>()
+    const dialogStatus = ref(DIALOG_STATUS.ADD)
+
+    const moduleDialogVisible = ref(false)
+    const moduleDialogConfig = ref({})
+
+    const prepareFormVisible = ref(false)
+    const prepareDialogConfig = ref({})
+
+    const tableData = ref<IProductTableItem[]>([])
+    const tableSelectList = ref<IProductTableItem[]>([])
+
+    const ORDER_STATUS_REF = reactive(ORDER_STATUS)
+
+    const hasProduction = computed(() =>
+      tableData.value.find((item) => item.status === ORDER_STATUS.PRODUCTION)
+    )
+    const { systemConfig } = useGlobalState()
+
+    // 1鑷姩锛�0鎵嬪姩
+    const controlMode = computed(() => {
+      const { ExecuteMode } = systemConfig.state.value
+      return ExecuteMode == '0'
+    })
+    /**
+     * 浜х嚎
+     */
+    const hasProductionLineStructure = computed(() => {
+      const { ProductionLineStructure } = systemConfig.state.value
+      return ProductionLineStructure == 1
+    })
+    /**
+     * 寮�濮嬩俊鍙�
+     */
+    const StartVariableName = computed(() => {
+      return systemConfig.state.value?.StartVariableName
+    })
+    /**
+     * 瀹屾垚淇″彿
+     */
+    const FinishVariableName = computed(() => {
+      return systemConfig.state.value?.FinishVariableName
+    })
+    const productionStatus = computed(() => {
+      if (StartVariableName.value) {
+        const v = Variable.store[StartVariableName.value]
+        if (v == 1) {
+          return _t('鐢熶骇涓�')
+        }
+        return _t('鏈敓浜�')
+      }
+      return _t('鏈敓浜�')
+    })
+
+    const callbackStack = ref([])
+    const callbackStatus = ref(false)
+
+    const tipParams = ref({
+      tipVisible: false,
+      tipText: '',
+      tipTextIcon: '',
+      noCancel: false,
+    })
+
+    const tableHead = computed(() => [
+      {
+        prop: 'code',
+        label: _t('宸ュ崟鍙�'),
+      },
+      {
+        prop: 'OuterDiameter',
+        label: _t('澶栧緞'),
+      },
+      {
+        prop: 'Material',
+        label: _t('鏉愯川'),
+      },
+      {
+        prop: 'Length',
+        label: _t('闀垮害'),
+      },
+      {
+        prop: 'CallMaterialStatus',
+        label: _t('鍙枡鐘舵��'),
+      },
+      {
+        prop: 'source',
+        label: _t('宸ュ崟鏉ユ簮'),
+      },
+      {
+        prop: 'productModel',
+        label: _t('浜у搧鍨嬪彿'),
+      },
+      {
+        prop: 'formulaName',
+        label: _t('宸ヨ壓閰嶆柟'),
+      },
+      {
+        prop: 'segments',
+        label: _t('宸ュ簭娈�'),
+      },
+      {
+        prop: 'planQty',
+        label: _t('璁″垝鏁伴噺'),
+      },
+      {
+        prop: 'produceQty',
+        label: _t('鎶曚骇鏁伴噺'),
+      },
+      {
+        prop: 'qualifiedQty',
+        label: _t('鍚堟牸鏁�'),
+      },
+      {
+        prop: 'progress',
+        label: _t('宸ュ崟鐢熶骇杩涘害'),
+      },
+      {
+        prop: 'shift',
+        label: _t('鐝'),
+      },
+      {
+        prop: 'planStartTime',
+        label: _t('璁″垝寮�濮嬫椂闂�'),
+        width: 180,
+      },
+      {
+        prop: 'planFinishTime',
+        label: _t('璁″垝缁撴潫鏃堕棿'),
+        width: 180,
+      },
+      {
+        prop: 'statusName',
+        label: _t('宸ュ崟鐘舵��'),
+      },
+    ])
+
+    const currentTableHead = computed(() => {
+      return (status: number) => {
+        let head
+        if (hasProductionLineStructure.value) {
+          if ([1, 0, -1, -2].includes(status)) {
+            head = tableHead.value
+          } else {
+            head = tableHead.value.filter((item) => {
+              return item.prop !== 'segments'
+            })
+          }
+        } else {
+          head = tableHead.value.filter((item) => item.prop !== 'segments')
+        }
+        if (status == -2) {
+          head = head.filter((item) => {
+            return ![
+              'produceQty',
+              'qualifiedQty',
+              'progress',
+              'shift',
+            ].includes(item.prop)
+          })
+        }
+        return head
+      }
+    })
+
+    const onChangeDate = () => {
+      const startTime = timeRange.value?.[0]
+      const endTime = timeRange.value?.[1]
+      console.log('onChangeDate', startTime, endTime)
+      initAllTableData()
+    }
+
+    const onAdd = () => {
+      if (!isHasPermission('OrderManagement-actions-add')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      dialogStatus.value = DIALOG_STATUS.ADD
+      dialogVisible.value = true
+    }
+
+    const onEdit = async (tableSelectList: IProductTableItem[] = []) => {
+      if (!isHasPermission('OrderManagement-actions-update')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      if (tableSelectList.length !== 1) {
+        ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+        return
+      }
+
+      const id = get(head(tableSelectList), 'id', '')
+
+      const result = await api.getOrder(id)
+
+      dialogConfig.value = result
+      console.log('result', result)
+      dialogStatus.value = DIALOG_STATUS.EDIT
+      dialogVisible.value = true
+    }
+
+    const onDelete = async (tableSelectList: IProductTableItem[] = []) => {
+      if (!isHasPermission('OrderManagement-actions-delete')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      if (!tableSelectList.length) {
+        ElMessage.warning(_t('璇疯嚦灏戦�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+        return
+      }
+      // // 鏄惁瀛樺湪 寰呯敓浜� 浠ュ鐨勭姸鎬�
+      // const onlyProduced = tableSelectList.every(
+      //   (item) => item.status === ORDER_STATUS.PRODUCED
+      // )
+
+      // 妫�娴嬫槸鍚﹀伐鍗曟潵婧愨�樻湰鍦板垱寤衡�� 浠ュ
+      const isLocalSource = tableSelectList.every(
+        (item: any) => item.source === _t('宸ュ崟鏉ユ簮')
+      )
+
+      if (isLocalSource) {
+        return ElMessage.error(_t('鍒犻櫎澶辫触锛佸伐鍗曟潵婧愰潪鏈湴鍒涘缓锛屼笉鏀寔鍒犻櫎'))
+      }
+
+      // if (!onlyProduced) {
+      //   setTipParams(true, '鎿嶄綔澶辫触锛佷粎鏀寔鍒犻櫎宸ュ崟鐘舵�佷负寰呯敓浜х殑宸ュ崟锛岃妫�鏌ュ悗閲嶈瘯', 'cuowutishi')
+      //   return
+      // }
+
+      const func = async () => {
+        const ids = tableSelectList.map((item) => item.id)
+        await api.delOrder(ids)
+        ElMessage.success(_t(`鍒犻櫎鎴愬姛`))
+        initAllTableData()
+      }
+
+      setTipParams(true, _t('宸ュ崟鍒犻櫎鍚庝笉鍙仮澶嶏紝鏄惁纭鍒犻櫎'), '')
+
+      // @ts-ignore
+      callbackStack.value.push(() => {
+        return callbackStatus.value ? func() : Promise.resolve
+      })
+    }
+
+    const onDeliver = async (
+      tableSelectList: IProductTableItem[] = [],
+      status?: string | number
+    ) => {
+      if (!isHasPermission('OrderManagement-actions-deliver')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+
+      segmentConfig.value.row = {
+        // ids,
+        tableSelectList,
+      }
+
+      onDeliverThen()
+    }
+    // const onSegmentConfirm = (segments: string[]) => {
+    //   onDeliverThen()
+    // }
+    const onDeliverThen = () => {
+      const { tableSelectList }: any = segmentConfig.value.row
+      const ids = tableSelectList.map((item) => item.id)
+      const func = async () => {
+        await api.batchPutDeliver(ids)
+        onClearTable()
+        ElMessage.success(_t('鎿嶄綔鎴愬姛'))
+        initAllTableData()
+      }
+
+      // setTipParams(true, '涓嬪彂宸ュ崟鍓嶈纭繚瀹屾垚娓呯嚎鎿嶄綔锛屾槸鍚︾‘璁や笅鍙戝伐鍗曪紵', '')
+
+      // @ts-ignore
+      callbackStack.value.push(() => {
+        return callbackStatus.value ? func() : Promise.resolve
+      })
+
+      nextTick(() => tipConfirm('confirm'))
+    }
+    const onClearTable = () => {
+      if (Array.isArray(colRef.value)) {
+        colRef.value.forEach((rf) => {
+          const s = rf?.status?.()
+          if ([1, 0].includes(s)) {
+            rf?.onClearAll?.()
+          }
+        })
+      }
+    }
+    const onPause = async (tableSelectList: IProductTableItem[] = []) => {
+      if (!isHasPermission('OrderManagement-actions-pause')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+
+      // if (tableSelectList.length !== 1) {
+      //   ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+      //   return
+      // }
+
+      const ids = tableSelectList.map((item) => item.id)
+
+      const func = async () => {
+        await api.batchPutPause(ids)
+        onClearTable()
+        ElMessage.success(_t('鎿嶄綔鎴愬姛'))
+
+        initAllTableData()
+      }
+
+      setTipParams(
+        true,
+        _t('宸ュ崟鏆傚仠鍚庯紝宸蹭笂绾夸骇鍝佷細缁х画鐢熶骇锛屾槸鍚︾‘璁ゆ殏鍋滃伐鍗曪紵'),
+        ''
+      )
+
+      // @ts-ignore
+      callbackStack.value.push(() => {
+        return callbackStatus.value ? func() : Promise.resolve
+      })
+    }
+    const onFinished = async (
+      tableSelectList: IProductTableItem[] = [],
+      s?: string | number
+    ) => {
+      if (!isHasPermission('OrderManagement-actions-finish')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+
+      // if (tableSelectList.length !== 1) {
+      //   ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+      //   return
+      // }
+
+      const ids = tableSelectList.map((item) => item.id)
+      const status = get(head(tableSelectList), 'status', '')
+
+      if (status === ORDER_STATUS.PRODUCTION) {
+        await ElMessageBox.confirm(
+          _t(`宸ュ崟姝e湪鐢熶骇锛屾槸鍚﹀己鍒剁粨鏉燂紵`),
+          _t('鎻愮ず'),
+          {
+            confirmButtonText: _t('纭'),
+            cancelButtonText: _t('鍙栨秷'),
+            type: 'info',
+          }
+        )
+      }
+
+      moduleDialogConfig.value = {
+        ids,
+        segmentId: tableSelectList[0]?.segments?.[0]?.value,
+      }
+      moduleDialogVisible.value = true
+    }
+    const onRevoke = async (
+      tableSelectList: IProductTableItem[] = [],
+      status?: string | number
+    ) => {
+      // if (!tableSelectList.length) {
+      //   ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+      //   return
+      // }
+
+      const func = async () => {
+        const ids = tableSelectList.map((item) => item.id)
+
+        await api.batchPutRevoke(ids)
+        ElMessage.success(_t(`鎾ら攢鎴愬姛`))
+        initAllTableData()
+      }
+
+      setTipParams(
+        true,
+        _t('宸ュ崟鎾ら攢鍚庯紝鐘舵�佸彉涓哄垵濮嬪緟婵�娲荤姸鎬�;鏄惁纭鎾ら攢宸ュ崟锛�'),
+        ''
+      )
+
+      // @ts-ignore
+      callbackStack.value.push(() => {
+        return callbackStatus.value ? func() : Promise.resolve
+      })
+    }
+    const onActivation = async (
+      tableSelectList: IProductTableItem[] = [],
+      status?: string | number
+    ) => {
+      // if (tableSelectList.length !== 1) {
+      //   ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+      //   return
+      // }
+
+      const ids = tableSelectList.map((item) => item.id)
+
+      const result = await api.batchPrepareActive(ids)
+      ElMessage.success(_t(`婵�娲绘垚鍔焋))
+      initAllTableData()
+
+      if (result.length) {
+        prepareFormVisible.value = true
+        prepareDialogConfig.value = {
+          ...head(tableSelectList),
+          tableData: result,
+        }
+      }
+    }
+    const onComplete = async (
+      tableSelectList: IProductTableItem[] = [],
+      status?: string | number
+    ) => {
+      // if (tableSelectList.length !== 1) {
+      //   ElMessage.warning(_t('璇烽�夋嫨涓�涓伐鍗曡繘琛屾搷浣�'))
+      //   return
+      // }
+      const func = async () => {
+        const ids = tableSelectList.map((item) => item.id)
+        await api.batchPutComplete(ids)
+        onClearTable()
+        ElMessage.success(_t(`瀹屾垚鎴愬姛`))
+        initAllTableData()
+      }
+      setTipParams(true, _t('鏄惁纭瀹屾垚宸ュ崟锛�'), '')
+      // @ts-ignore
+      callbackStack.value.push(() => {
+        return callbackStatus.value ? func() : Promise.resolve
+      })
+    }
+    const onActions = async (data: any) => {
+      const ACTION_MAP = {
+        [ORDER_ACTIONS_STATUS.DELIVER]: onDeliver,
+        [ORDER_ACTIONS_STATUS.PAUSE]: onPause,
+        [ORDER_ACTIONS_STATUS.FINISHED]: onFinished,
+        [ORDER_ACTIONS_STATUS.REVOKE]: onRevoke,
+        [ORDER_ACTIONS_STATUS.EDIT]: onEdit,
+        [ORDER_ACTIONS_STATUS.DELETE]: onDelete,
+        [ORDER_ACTIONS_STATUS.ACTIVATION]: onActivation,
+        [ORDER_ACTIONS_STATUS.COMPLTE]: onComplete,
+        [ORDER_ACTIONS_STATUS.UPLOAD]: onImport,
+        [ORDER_ACTIONS_STATUS.DOWNLOADTEMPLATE]: onDownloadTemplate,
+      }
+      if (data.type == ORDER_ACTIONS_STATUS.UPLOAD) {
+        onImport(data.data)
+        return
+      }
+      const type = get(data, 'type')
+      const func = ACTION_MAP[type]
+
+      if (!func) return
+
+      const params = get(data, 'data.tableSelectList', [])
+
+      func(params, get(data, 'status'))
+    }
+    // 鍒嗛〉閰嶇疆
+    const paginationConfig = reactive<{
+      pageSize: number
+      currentPage: number
+      total: number
+    }>({
+      pageSize: 50, // X鏉�/椤�
+      currentPage: 1, // 褰撳墠绗琗椤�
+      total: 0, // 鎬诲叡X椤�
+    })
+
+    const handleSelectionChange = (val: IProductTableItem[]) => {
+      tableSelectList.value = val
+    }
+
+    const onExport = async () => {
+      if (!isHasPermission('OrderManagement-actions-export')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      const params = {
+        Filter: '',
+        StartTime: '',
+        FinishTime: '',
+        Status: '',
+        Sorting: '',
+        SkipCount:
+          (paginationConfig.currentPage - 1) * paginationConfig.pageSize + '',
+        MaxResultCount: paginationConfig.pageSize + '',
+      }
+      // const result = await api.exportOrder(params)
+
+      await downloadFile({
+        fileUrl: '/api/v1/ordermanagement/order/export',
+        fileName: `${_t('宸ュ崟')}_${
+          new Date().getFullYear() +
+          Number(new Date().getMonth() + 1) +
+          new Date().getDate() +
+          new Date().getTime()
+        }.xlsx`,
+        params,
+      })
+    }
+
+    const onDownloadTemplate = async () => {
+      if (!isHasPermission('OrderManagement-actions-download')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      downloadFile({
+        fileUrl: '/api/v1/ordermanagement/order/download',
+        fileName: `${_t('宸ュ崟妯$増')}${
+          new Date().getFullYear() +
+          Number(new Date().getMonth() + 1) +
+          new Date().getDate() +
+          new Date().getTime()
+        }.xlsx`,
+      })
+    }
+    // @ts-ignore
+    const onImport = async (file) => {
+      if (!isHasPermission('OrderManagement-actions-import')) {
+        // ElMessage.error(_t('鐢ㄦ埛娌℃湁璇ユ潈闄愶紒'))
+        return
+      }
+      let formData = new FormData()
+      formData.append('file', file.file)
+
+      try {
+        await api.postImport(formData)
+        ElMessage.success(_t('鎿嶄綔鎴愬姛'))
+      } catch (error) {
+        console.log(error)
+      } finally {
+        initAllTableData()
+      }
+    }
+
+    // @ts-ignore
+    // function downloadFile(file, fileName) {
+    //   const blob = new Blob([file])
+    //   // 鍏煎涓嶅悓娴忚鍣ㄧ殑URL瀵硅薄
+    //   // const url:any = window.URL || window.webkitURL || window.moxURL
+    //   const url = window.URL || window.webkitURL
+    //   // 鍒涘缓涓嬭浇閾炬帴
+    //   const downloadHref = url.createObjectURL(blob)
+    //   // 鍒涘缓a鏍囩骞朵负鍏舵坊鍔犲睘鎬�
+    //   let downloadLink = document.createElement('a')
+    //   downloadLink.href = downloadHref
+    //   downloadLink.download = fileName
+    //   // 瑙﹀彂鐐瑰嚮浜嬩欢鎵ц涓嬭浇
+    //   downloadLink.click()
+    //   // @ts-ignore
+    //   window.URL.revokeObjectURL(url)
+    // }
+    聽 // @ts-ignore
+聽 聽 function downloadFile(file, fileName) {
+聽 聽 聽 const blob = new Blob([file])
+聽 聽 聽 // 鍏煎涓嶅悓娴忚鍣ㄧ殑URL瀵硅薄
+聽 聽 聽 // const url:any = window.URL || window.webkitURL || window.moxURL
+聽 聽 聽 const url = window.URL || window.webkitURL
+聽 聽 聽 // 鍒涘缓涓嬭浇閾炬帴
+聽 聽 聽 const downloadHref = url.createObjectURL(blob)
+聽 聽 聽 // 鍒涘缓a鏍囩骞朵负鍏舵坊鍔犲睘鎬�
+聽 聽 聽 let downloadLink = document.createElement('a')
+聽 聽 聽 downloadLink.href = downloadHref
+聽 聽 聽 downloadLink.download = fileName
+聽 聽 聽 // 瑙﹀彂鐐瑰嚮浜嬩欢鎵ц涓嬭浇
+聽 聽 聽 downloadLink.click()
+聽 聽 聽 // @ts-ignore
+聽 聽 聽 window.URL.revokeObjectURL(url)
+聽 聽 }
+
+    const updateFn = (data: any) => {
+      ProductModel.value = data
+
+      initAllTableData()
+    }
+
+    const onPage = (config: any) => {
+      condition.value.page[config.status] = config.currentPage
+      initTableData(config.status, config.segment)
+    }
+
+    const onEmitSegment = (config) => {
+      initTableData(config.status, config.id)
+    }
+
+    async function initTableData(Status = '', SegmentId = undefined) {
+      const skipCount =
+        condition.value.page[Status] || condition.value.currentPage
+
+      const StartTime = timeRange.value?.[0] || ''
+      const FinishTime = timeRange.value?.[1] || ''
+      const params = {
+        Filter: condition.value.Filter,
+        StartTime,
+        FinishTime,
+        Status,
+        Sorting: '',
+        Product: ProductModel.value.ProductModel,
+        SkipCount: (skipCount - 1) * condition.value.pageSize + '',
+        MaxResultCount: condition.value.pageSize + '',
+        SegmentId,
+      }
+
+      const result = await api.getTable(params)
+      const data = get(result, 'items', []).map((item, index) => {
+        // @ts-ignore
+        const { sort } = item
+        return {
+          ...item,
+          formulaName: item.formula?.name,
+          statusName: item.status?.description,
+          sort: isNull(sort) ? index : sort,
+        }
+      })
+
+      if (collapseOptions.value[Status]) {
+        collapseOptions.value[Status].tableData = cloneDeep(data)
+        collapseOptions.value[Status].attrsProp.total = paginationConfig.total =
+          get(result, 'totalCount', 0)
+      }
+    }
+    async function initTableHead() {}
+    const initProdCode = async () => {
+      const result = await api.getModelOptionsNew()
+      result.unshift({
+        name: _t('涓嶉檺'),
+        value: '',
+        description: _t('涓嶉檺'),
+      })
+      prodCodeList.value = result
+      initAllTableData()
+    }
+    function initAllTableData(statusList = [1, 0, -1, -2]) {
+      Object.keys(collapseOptions.value).forEach((status: string) => {
+        const segment = orderSegMap.value[status]
+        if (statusList.includes(Number(status))) {
+          initTableData(status, segment)
+        }
+      })
+    }
+    Language.useChange(() => {
+      initProdCode()
+    })
+
+    onMounted(() => {
+      initProdCode()
+    })
+
+    const tipConfirm = async (action: 'cancel' | 'confirm') => {
+      if (!callbackStack.value.length) {
+        setTipParams()
+        return
+      }
+
+      callbackStatus.value = action === 'confirm'
+
+      const ajaxFunc = callbackStack.value.pop()
+      if (!ajaxFunc) return
+
+      try {
+        // @ts-ignore
+        await ajaxFunc()
+      } catch (error) {
+        console.log(' callbackStack list error', error)
+      } finally {
+        callbackStack.value = []
+      }
+
+      setTipParams()
+    }
+
+    const onCloseDialog = () => {
+      moduleDialogVisible.value = false
+      initAllTableData()
+    }
+    function setTipParams(
+      tipVisible = false,
+      tipText = '',
+      tipTextIcon = '',
+      noCancel?: boolean
+    ) {
+      tipParams.value = {
+        tipVisible,
+        tipText,
+        tipTextIcon,
+        noCancel: noCancel || false,
+      }
+    }
+
+    function init() {
+      initTableHead()
+    }
+
+    init()
+
+    const callback = () => {
+      dialogVisible.value = false
+      initAllTableData()
+    }
+
+    const prepareCallback = () => {
+      prepareFormVisible.value = false
+      prepareDialogConfig.value = {}
+      initAllTableData()
+    }
+
+    // @ts-ignore
+    // function downloadFile(file, fileName) {
+    //   const blob = new Blob([file])
+    //   // 鍏煎涓嶅悓娴忚鍣ㄧ殑URL瀵硅薄
+    //   // const url:any = window.URL || window.webkitURL || window.moxURL
+    //   const url = window.URL || window.webkitURL
+    //   // 鍒涘缓涓嬭浇閾炬帴
+    //   const downloadHref = url.createObjectURL(blob)
+    //   // 鍒涘缓a鏍囩骞朵负鍏舵坊鍔犲睘鎬�
+    //   let downloadLink = document.createElement('a')
+    //   downloadLink.href = downloadHref
+    //   downloadLink.download = fileName
+    //   // 瑙﹀彂鐐瑰嚮浜嬩欢鎵ц涓嬭浇
+    //   downloadLink.click()
+    //   // @ts-ignore
+    //   window.URL.revokeObjectURL(url)
+    // }
+
+    // const onEmitWatch = () => {
+    //   const socket = new Socket({
+    //       url: '/hubs/v1/easy-notice',
+    //       name: '宸ュ崟绠$悊',
+    //     })
+
+    //     socket?.connection?.start()
+    //     socket?.on('onMessage', () => {
+
+    //     })
+    // }
+
+    const onEmitStartFlush = () => {
+      if (!controlMode.value) {
+        clearInterval(t)
+        isStartFlushList.value = true
+        t = setInterval(() => {
+          initAllTableData([0, 1, -1])
+        }, 5000)
+      }
+    }
+    const onEmitAction = (value) => {
+      if (value === 1) {
+        if (StartVariableName.value) {
+          VariableStore[StartVariableName.value] = 1
+          VariableStore[FinishVariableName.value] = 0
+          return ElMessage.success(_t('寮�濮嬫垚鍔�'))
+        }
+        return ElMessage.warning(_t(`璇烽厤缃彉閲廯))
+      }
+      if (value === 0) {
+        if (FinishVariableName.value) {
+          VariableStore[FinishVariableName.value] = 1
+          VariableStore[StartVariableName.value] = 0
+          clearInterval(t)
+          isStartFlushList.value = false
+          return ElMessage.success(_t('鍋滄鎴愬姛'))
+        }
+        return ElMessage.warning(_t(`璇烽厤缃彉閲廯))
+      }
+    }
+    watch(
+      () => Variable.store[StartVariableName.value],
+      (v) => {
+        if (v == 1) {
+          clearTimeout(t)
+          onEmitStartFlush()
+        }
+      },
+      {
+        immediate: true,
+      }
+    )
+    onUnmounted(() => {
+      isStartFlushList.value = false
+      clearInterval(t)
+    })
+
+    return {
+      condition,
+      collapseOptions,
+      collapseList,
+      tableHead,
+      tableData,
+      paginationConfig,
+      dialogVisible,
+      dialogConfig,
+      dialogStatus,
+      moduleDialogVisible,
+      moduleDialogConfig,
+      prepareFormVisible,
+      prepareDialogConfig,
+      hasProduction,
+      tipParams,
+      columnsFilter,
+      timeRange,
+      prodCodeList,
+      ProductModel,
+      ORDER_STATUS_REF,
+      currentTableHead,
+      segmentConfig,
+      _t,
+      productionStatus,
+      controlMode,
+      isStartFlushList,
+      colRef,
+      onClearTable,
+      onEmitSegment,
+      onEmitAction,
+      onDeliverThen,
+      onAdd,
+      onEdit,
+      onDelete,
+      onDeliver,
+      onPause,
+      onFinished,
+      onActions,
+      callback,
+      prepareCallback,
+      handleSelectionChange,
+      onExport,
+      onImport,
+      onDownloadTemplate,
+      tipConfirm,
+      onCloseDialog,
+      initAllTableData,
+      initProdCode,
+      onChangeDate,
+      updateFn,
+      onPage,
+    }
+  },
+})
+</script>
+<style lang="scss" scoped>
+@import '@/assets/styles/common.scss';
+
+.container {
+  height: 100%;
+  overflow: auto;
+  .header-status {
+    background-color: #f1f1f1;
+    border-radius: 5px;
+    display: flex;
+    justify-content: flex-start;
+    height: 40px;
+    width: 100%;
+    align-items: center;
+    font-size: 14px;
+    padding: 0 10px;
+    margin-bottom: 10px;
+    .status {
+      border: 1px solid #ddd;
+      border-radius: 4px;
+      font-size: 14px;
+      min-width: 80px;
+      padding: 2px 10px;
+      display: flex;
+      align-content: center;
+      justify-content: center;
+      margin: 0 10px;
+      background-color: #fff;
+      height: 26px;
+    }
+  }
+}
+
+.head {
+  display: flex;
+  justify-content: space-between;
+
+  .head-left {
+    display: flex;
+    justify-content: flex-start;
+    align-items: center;
+  }
+
+  :deep(.cs-input__wrapper) {
+    height: 32px;
+  }
+}
+
+.right-btn {
+  color: #484f53;
+  background-color: #fff;
+}
+
+.sortClass {
+  border-radius: 50%;
+  color: #fff;
+  border: 1px solid #c7c9cc;
+  background-color: #c7c9cc;
+  padding: 3px;
+  font-size: 8px;
+  cursor: pointer;
+
+  &:last-child {
+    margin-left: 8px;
+  }
+
+  &:hover {
+    background-color: #5a84ff;
+    border-color: #5a84ff;
+  }
+}
+
+.head-right {
+  display: flex;
+  align-items: center;
+}
+
+.prohibit {
+  cursor: no-drop;
+
+  &:hover {
+    border: 1px solid #c7c9cc;
+    background-color: #c7c9cc;
+  }
+}
+</style>
+<style lang="scss">
+@import url(../../../../assets/styles/common.scss);
+</style>

--
Gitblit v1.9.3