Browse Source

变更令

ZaiZai 1 year ago
parent
commit
99ef9eb1e8

+ 29 - 17
src/views/alter/admin/components/order/addModal.vue

@@ -113,26 +113,26 @@
                         <div class="hc-table-ref-box no-border">
                             <el-table class="w-full" :data="tableData1" row-key="id" height="100%" highlight-current-row border>
                                 <el-table-column type="index" label="序号" />
-                                <el-table-column prop="key1" label="清单编号" />
-                                <el-table-column prop="key2" label="清单名称" />
-                                <el-table-column prop="key3" label="单价" />
+                                <el-table-column prop="formNumber" label="清单编号" />
+                                <el-table-column prop="formName" label="清单名称" />
+                                <el-table-column prop="currentPrice" label="单价" />
                                 <el-table-column label="数量" align="center">
-                                    <el-table-column prop="key5" label="变更前" />
-                                    <el-table-column prop="key6" label="变更增减">
-                                        <template #default="{ row }">
-                                            <hc-table-input v-model="row.key6" />
+                                    <el-table-column prop="contractTotal" label="变更前" />
+                                    <el-table-column prop="currentChangeTotal" label="变更增减">
+                                        <template #default="scope">
+                                            <hc-table-input v-model="scope.row.currentChangeTotal" />
                                         </template>
                                     </el-table-column>
-                                    <el-table-column prop="key7" label="变更后" />
+                                    <el-table-column prop="changeTotal" label="变更后" />
                                 </el-table-column>
                                 <el-table-column label="金额" align="center">
-                                    <el-table-column prop="key8" label="变更前" />
-                                    <el-table-column prop="key9" label="变更增减" />
-                                    <el-table-column prop="key10" label="变更后" />
+                                    <el-table-column prop="contractMoney" label="变更前" />
+                                    <el-table-column prop="currentChangeMoney" label="变更增减" />
+                                    <el-table-column prop="changeMoney" label="变更后" />
                                 </el-table-column>
                                 <el-table-column prop="action" label="操作" width="80" align="center">
-                                    <template #default="{ row }">
-                                        <el-link type="danger">删除</el-link>
+                                    <template #default="scope">
+                                        <el-link type="danger" @click="tableFormListDel(scope.$index)">删除</el-link>
                                     </template>
                                 </el-table-column>
                             </el-table>
@@ -154,7 +154,7 @@
         <ChangePre v-model="isChangeQuoteShow" />
 
         <!-- 变更申请清单 -->
-        <ChangeRequest v-model="isChangeShow" />
+        <ChangeRequest v-model="isChangeShow" :ids="changeIds" :tree-id="changeNodeItem.id" :contract-id="contractId" @finish="changeNodeFinish" />
     </hc-new-dialog>
 </template>
 
@@ -162,7 +162,7 @@
 import { nextTick, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { getDictionaryData } from '~uti/tools'
-import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { arrToKey, getArrValue, getObjValue, isNullES } from 'js-fast-way'
 
 //子组件
 import ChangeRequest from './changeRequest.vue'
@@ -322,23 +322,35 @@ const delChangeNode = (index) => {
 
 //变更申请部位 行被点击
 const changeNodeItem = ref({})
+const tableData1 = ref([])
 const rowChangeNodeClick = ({ row }) => {
     changeNodeItem.value = row
+    tableData1.value = getArrValue(row.formList)
+}
+
+//删除变更申请清单
+const tableFormListDel = (index) => {
+    tableData1.value.splice(index, 1)
 }
 
-//变更申请清单
-const tableData1 = ref([])
 //变更清单的添加弹窗
 const isChangeShow = ref(false)
+const changeIds = ref('')
 const changeShowClick = () => {
     const row = changeNodeItem.value
     if (isNullES(row.id)) {
         window.$message.warning('请先选择变更申请部位')
         return false
     }
+    changeIds.value = arrToKey(tableData1.value, 'id')
     isChangeShow.value = true
 }
 
+//确认选择完成
+const changeNodeFinish = (data) => {
+    console.log(data)
+}
+
 
 //引用预变更的弹窗
 const isChangeQuoteShow = ref(false)

+ 70 - 35
src/views/alter/admin/components/order/changeRequest.vue

@@ -3,32 +3,39 @@
         <hc-card-item>
             <template #header>
                 <div class="w-60">
-                    <el-input v-model="searchForm.key1" placeholder="清单编号" />
+                    <hc-search-input v-model="searchForm.searchValue" placeholder="请输入清单编号" @search="searchClick" />
                 </div>
             </template>
             <template #extra>
-                <el-link type="primary">显示已分解</el-link>
+                <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"
             />
-            <template #action>
-                <hc-pages :pages="searchForm" @change="pageChange" />
-            </template>
         </hc-card-item>
     </hc-new-dialog>
 </template>
 
 <script setup>
 import { ref, watch } from 'vue'
+import { arrToKey, getArrValue } from 'js-fast-way'
+import mainApi from '~api/alter/admin/order'
 
 const props = defineProps({
     ids: {
         type: [String, Number],
         default: '',
     },
+    treeId: {
+        type: [String, Number],
+        default: '',
+    },
+    contractId: {
+        type: [String, Number],
+        default: '',
+    },
 })
 
 //事件
@@ -43,50 +50,82 @@ const isShow = defineModel('modelValue', {
 //监听
 watch(() => [
     props.ids,
-], ([ids]) => {
-    console.log('ids', ids)
-}, { immediate: true })
+    props.treeId,
+    props.contractId,
+], ([id, tid, cid]) => {
+    searchForm.value.ids = id
+    searchForm.value.nodeId = tid
+    searchForm.value.contractId = cid
+}, { deep: true })
 
 //监听
 watch(isShow, (val) => {
     if (val) {
-        console.log('isShow', val)
+        getTableData()
     }
 })
 
+//搜索
+const searchClick = () => {
+    getTableData()
+}
+
+//显示类型
+const showTypeClick = () => {
+    const { showType } = searchForm.value
+    searchForm.value.showType = showType === 1 ? 2 : 1
+    getTableData()
+}
+
 //搜索表单
 const searchForm = ref({
-    key1: null, current: 1, size: 10, total: 0,
+    searchValue: null, showType: 1, nodeId: props.treeId,
+    ids: props.ids, contractId: props.contractId,
 })
 
-//分页
-const pageChange = ({ current, size }) => {
-    searchForm.value.current = current
-    searchForm.value.size = size
-}
-
 //表格数据
 const tableLoading = ref(false)
 const tableColumn = ref([
-    { key: 'key1', name: '清单编号' },
-    { key: 'key2', name: '清单名称' },
-    { key: 'key3', name: '单价(元)' },
-    { key: 'key4', name: '合同数量' },
-    { key: 'key5', name: '合同变更后数量' },
-    { key: 'key6', name: '施工图变更后数量' },
-    { key: 'key7', name: '分解剩余量' },
+    { 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([
-    { key1: '1111' },
-])
-
-const tableCheckChange = () => {
+const tableData = ref([])
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { data } = await mainApi.addForm({
+        ...searchForm.value,
+        contractId: props.contractId,
+    })
+    tableData.value = getArrValue(data)
+    tableLoading.value = false
+}
 
+//表格勾选
+const tableCheck = ref([])
+const tableCheckChange = (rows) => {
+    tableCheck.value = rows
 }
 
-const addModalSave = () => {
-    emit('finish')
-    addModalClose()
+//保存
+const addModalSave = async () => {
+    const ids = arrToKey(tableCheck.value, 'id')
+    const { error, code, msg, data } = await mainApi.getSelectForm({
+        ids: ids,
+        nodeId: props.treeId,
+        contractId: props.contractId,
+    })
+    if (!error && code === 200) {
+        addModalClose()
+        emit('finish', getArrValue(data))
+    } else {
+        window.$message.error(msg ?? '确认失败')
+    }
 }
 
 //关闭弹窗
@@ -95,7 +134,3 @@ const addModalClose = () => {
     emit('close')
 }
 </script>
-
-<style scoped lang="scss">
-
-</style>