Sfoglia il codice sorgente

任务的变更令

ZaiZai 1 anno fa
parent
commit
a08285c945

+ 21 - 10
src/views/tasks/components/hc-data/alter-form.vue

@@ -133,7 +133,7 @@
         <!-- 变更申请清单 -->
         <hc-card-item title="变更申请清单" class="mt-3">
             <template #extra>
-                <el-link type="primary" @click="changeShowClick">添加</el-link>
+                <el-link type="primary" :disabled="!isEdits || tableInfo.status === 2" @click="changeShowClick">添加</el-link>
             </template>
             <div class="hc-table-ref-box no-border">
                 <el-table class="w-full" :data="tableData[tableIndex]?.formList" row-key="id" height="100%" highlight-current-row border>
@@ -178,16 +178,16 @@
             </el-form>
         </hc-card-item>
         <!-- 变更申请清单 -->
-        <ChangeRequest v-model="isChangeShow" :ids="changeIds" :tree-id="changeNodeItem.id" :contract-id="contractId" @finish="changeNodeFinish" />
+        <ChangeRequest v-model="isChangeShow" :info="changeNodeInfo" @finish="changeNodeFinish" />
         <!-- 文件上传组件 -->
         <hc-upload-file ref="uploadFileRef" :options="uploadFileOptions" @success="uploadFileSuccess" />
     </div>
 </template>
 
 <script setup>
-import { onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import ChangeRequest from '~src/views/alter/admin/components/order/changeRequest.vue'
+import ChangeRequest from './changeRequest.vue'
 import { delMessage, getDictionaryData, isNumberReg } from '~uti/tools'
 import { arrIndex, arrToKey, getArrValue, getObjVal, getObjValue, isArray, isNullES } from 'js-fast-way'
 import { getHeader } from 'hc-vue3-ui'
@@ -397,19 +397,30 @@ const tableFormListDel = (row, index) => {
 
 //变更清单的添加弹窗
 const isChangeShow = ref(false)
-const changeIds = ref('')
+const changeNodeInfo = ref({})
 const changeShowClick = () => {
-    if (isNullES(changeNodeItem.value['id'])) {
+    const {id, primaryKeyId} = changeNodeItem.value
+    if (isNullES(id)) {
         window.$message.warning('请先选择变更申请部位')
         return false
     }
-    changeIds.value = arrToKey(tableData.value[tableIndex.value].formList, 'id')
-    isChangeShow.value = true
+    //处理数据
+    const ids = arrToKey(tableData.value[tableIndex.value].formList, 'id')
+    changeNodeInfo.value = {
+        ids: ids,
+        treeId: id ?? '',
+        primaryKeyIdMeter: primaryKeyId ?? '',
+        dataId: tableInfo.value.id ?? '',
+        taskId: taskInfo.value.id ?? '',
+    }
+    nextTick(() => {
+        isChangeShow.value = true
+    })
 }
 
 //确认选择完成
-const changeNodeFinish = (data) => {
-    tableData.value[tableIndex.value].formList.push(...data)
+const changeNodeFinish = () => {
+    getDataDetail()
 }
 
 //变更增减的输入框获得焦点

+ 136 - 0
src/views/tasks/components/hc-data/changeRequest.vue

@@ -0,0 +1,136 @@
+<template>
+    <hc-new-dialog is-table widths="90%" :show="isShow" title="变更清单添加" @save="addModalSave" @close="addModalClose">
+        <hc-card-item>
+            <template #header>
+                <div class="w-60">
+                    <hc-search-input v-model="searchForm.searchValue" placeholder="请输入清单编号" @search="searchClick" />
+                </div>
+            </template>
+            <template #extra>
+                <el-link type="primary" @click="showTypeClick">{{ searchForm.showType === 1 ? '显示已分解' : '显示所有' }}</el-link>
+            </template>
+            <hc-table
+                :column="tableColumn" :datas="tableData" :loading="tableLoading"
+                is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
+                @selection-change="tableCheckChange"
+            />
+        </hc-card-item>
+    </hc-new-dialog>
+</template>
+
+<script setup>
+import { nextTick, ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
+import { getArrValue } from 'js-fast-way'
+import orderApi from '~api/alter/admin/order'
+import mainApi from '~api/tasks/hc-data'
+
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//事件
+const emit = defineEmits(['finish', 'close'])
+
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
+
+//双向绑定
+// eslint-disable-next-line no-undef
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听数据
+const taskInfo = ref({})
+watch(() => props.info, (obj) => {
+    taskInfo.value = obj
+}, { immediate: true, deep: true })
+
+//监听
+watch(isShow, (val) => {
+    if (val) {
+        nextTick(() => {
+            getTableData()
+        })
+    }
+})
+
+//搜索
+const searchClick = () => {
+    getTableData()
+}
+
+//显示类型
+const showTypeClick = () => {
+    const { showType } = searchForm.value
+    searchForm.value.showType = showType === 1 ? 2 : 1
+    getTableData()
+}
+
+//搜索表单
+const searchForm = ref({ searchValue: null, showType: 1})
+
+//表格数据
+const tableLoading = ref(false)
+const tableColumn = ref([
+    { key: 'formNumber', name: '清单编号', width: 120 },
+    { key: 'formName', name: '清单名称' },
+    { key: 'currentPrice', name: '单价(元)', width: 100 },
+    { key: 'contractTotal', name: '合同数量', width: 100 },
+    { key: 'changeTotal', name: '合同变更后数量', width: 120 },
+    { key: 'buildChangeTotal', name: '施工图变更后数量', width: 140 },
+    { key: 'resolveResidueTotal', name: '分解剩余量', width: 100 },
+])
+const tableData = ref([])
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const {ids, treeId} = taskInfo.value
+    const { data } = await orderApi.addForm({
+        ...searchForm.value,
+        projectId: projectId.value,
+        contractId: contractId.value,
+        nodeId: treeId ?? '',
+        ids: ids ?? '',
+    })
+    tableData.value = getArrValue(data)
+    tableLoading.value = false
+}
+
+//表格勾选
+const tableCheck = ref([])
+const tableCheckChange = (rows) => {
+    tableCheck.value = rows
+}
+
+//保存
+const addModalSave = async () => {
+    const {primaryKeyIdMeter, treeId, dataId, taskId} = taskInfo.value
+    const { error, code, msg } = await mainApi.changeTokenInventorySave({
+        projectId: projectId.value,
+        contractId: contractId.value,
+        primaryKeyIdMeter: primaryKeyIdMeter ?? '',
+        formList: tableCheck.value,
+        nodeId: treeId ?? '',
+        dataId: dataId ?? '',
+        taskId: taskId ?? '',
+    })
+    if (!error && code === 200) {
+        addModalClose()
+        emit('finish')
+    } else {
+        window.$message.error(msg ?? '确认失败')
+    }
+}
+
+//关闭弹窗
+const addModalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>