|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <hc-new-card>
|
|
|
+ <hc-new-card title="合同计量期">
|
|
|
<template #extra>
|
|
|
<el-button hc-btn type="primary" @click="editModalClick">
|
|
|
<HcIcon name="add" />
|
|
@@ -11,7 +11,7 @@
|
|
|
<hc-pages :pages="searchForm" @change="pageChange" />
|
|
|
</template>
|
|
|
<!-- 计量期编辑 -->
|
|
|
- <hc-new-dialog is-table widths="1200px" :show="editModalShow" title="计量期编辑" @save="editModalSave" @close="editModalClose">
|
|
|
+ <hc-new-dialog is-table widths="1200px" :show="editModalShow" title="计量期编辑" :loading="saveLoading" @save="editModalSave" @close="editModalClose">
|
|
|
<hc-card-item>
|
|
|
<template #header>
|
|
|
<el-tooltip :visible="editVisible" effect="light" placement="bottom-start">
|
|
@@ -32,40 +32,40 @@
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
- <el-button type="primary">
|
|
|
+ <el-button type="primary" @click="addPreRow">
|
|
|
<HcIcon name="page-separator" :line="false" />
|
|
|
<span>插入上一行</span>
|
|
|
</el-button>
|
|
|
- <el-button type="primary">
|
|
|
+ <el-button type="primary" @click="addNextRow">
|
|
|
<HcIcon name="page-separator" :line="false" />
|
|
|
<span>插入下一行</span>
|
|
|
</el-button>
|
|
|
</template>
|
|
|
- <hc-table is-new :index-style="{ width: 60 }" :column="tableEditColumn" :datas="tableEditData">
|
|
|
- <template #key1="{ row }">
|
|
|
- <hc-table-input v-model="row.key3" disabled />
|
|
|
+ <hc-table is-new :index-style="{ width: 60 }" :column="tableEditColumn" :datas="tableEditData" :loading="tableEditLoading" is-current-row @row-click="hangeRow">
|
|
|
+ <template #periodNumber="{ row }">
|
|
|
+ <hc-table-input v-model="row.periodNumber" :disabled="row.citeStatus" />
|
|
|
</template>
|
|
|
- <template #key2="{ row }">
|
|
|
- <el-select v-model="row.key2" placeholder="选择年份" filterable disabled block>
|
|
|
+ <template #periodYear="{ row }">
|
|
|
+ <el-select v-model="row.periodYear" placeholder="选择年份" filterable block>
|
|
|
<el-option v-for="item in yearData" :key="item" :label="item" :value="item" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
- <template #key3="{ row }">
|
|
|
- <el-select v-model="row.key3" placeholder="选择月份" filterable disabled block>
|
|
|
+ <template #periodMonth="{ row }">
|
|
|
+ <el-select v-model="row.periodMonth" placeholder="选择月份" filterable block>
|
|
|
<el-option v-for="item in monthData" :key="item" :label="item" :value="item" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
- <template #key4="{ row }">
|
|
|
- <el-date-picker v-model="row.key4" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
|
|
|
+ <template #startDate="{ row }">
|
|
|
+ <el-date-picker v-model="row.startDate" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" @change="changeStart($event, row)" />
|
|
|
</template>
|
|
|
- <template #key5="{ row }">
|
|
|
- <el-date-picker v-model="row.key5" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
|
|
|
+ <template #endDate="{ row }">
|
|
|
+ <el-date-picker v-model="row.endDate" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" @change="changeEnd($event, row)" />
|
|
|
</template>
|
|
|
- <template #key6="{ row }">
|
|
|
- <el-date-picker v-model="row.key6" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
|
|
|
+ <template #formPrintDate="{ row }">
|
|
|
+ <el-date-picker v-model="row.formPrintDate" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" />
|
|
|
</template>
|
|
|
- <template #action="{ row }">
|
|
|
- <el-link type="danger">删除</el-link>
|
|
|
+ <template #action="{ row, index }">
|
|
|
+ <el-link type="danger" @click="delRow(row, index)">删除</el-link>
|
|
|
</template>
|
|
|
</hc-table>
|
|
|
</hc-card-item>
|
|
@@ -76,7 +76,12 @@
|
|
|
<script setup>
|
|
|
import { onMounted, ref } from 'vue'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import { getMonthList, getYearList } from 'js-fast-way'
|
|
|
+import { getArrValue, getMonthList, getYearList } from 'js-fast-way'
|
|
|
+import mainApi from '~api/debit-pay/admin/periods.js'
|
|
|
+import { useAppStore } from '~src/store'
|
|
|
+const useAppState = useAppStore()
|
|
|
+const contractId = ref(useAppState.getContractId)
|
|
|
+const projectId = ref(useAppState.getProjectId)
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'DebitPayAdminPeriods',
|
|
@@ -89,7 +94,7 @@ const monthData = getMonthList()
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
-
|
|
|
+ getTableData()
|
|
|
})
|
|
|
|
|
|
//搜索表单
|
|
@@ -104,45 +109,148 @@ const pageChange = ({ current, 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: '报表打印日期' },
|
|
|
-])
|
|
|
-const tableData = ref([
|
|
|
- { key1: '1111' },
|
|
|
+ { key: 'periodNumber', name: '期号' },
|
|
|
+ { key: 'periodYear', name: '年份' },
|
|
|
+ { key: 'periodMonth', name: '月份' },
|
|
|
+ { key: 'startDate', name: '开始日期' },
|
|
|
+ { key: 'endDate', name: '结束日期' },
|
|
|
+ { key: 'endDate', name: '报表打印日期' },
|
|
|
])
|
|
|
-
|
|
|
+const tableData = ref([])
|
|
|
+const getTableData = async () => {
|
|
|
+ tableLoading.value = true
|
|
|
+ const { error, code, data } = await mainApi.getPage({
|
|
|
+ ...searchForm.value,
|
|
|
+ contractId:contractId.value,
|
|
|
+ type:1,
|
|
|
+ })
|
|
|
+ tableLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ tableData.value = getArrValue(data['records'])
|
|
|
+ } else {
|
|
|
+ tableData.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
//计量期编辑
|
|
|
const editVisible = ref(false)
|
|
|
const editModalShow = ref(false)
|
|
|
const editModalClick = () => {
|
|
|
editModalShow.value = true
|
|
|
+ getTableEditData()
|
|
|
}
|
|
|
+const curIndex = ref(0)
|
|
|
+const curRow = ref({})
|
|
|
+const hangeRow = ({ row })=>{
|
|
|
+ tableEditData.value.forEach((ele, index)=>{
|
|
|
+ if (row.id === ele.id) {
|
|
|
+ curIndex.value = index
|
|
|
+ curRow.value = ele
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+const addPreRow = ()=>{
|
|
|
+ tableEditData.value.splice( curIndex.value, 0, { isNew:true })
|
|
|
+}
|
|
|
+const addNextRow = ()=>{
|
|
|
+ console.log(curRow.value?.startDate, 'curRow.value?.startDate')
|
|
|
+ if (!curRow.value?.startDate) {
|
|
|
+ curRow.value.startDate = tableEditData.value[0].startDate
|
|
|
+ }
|
|
|
+ const netxtDay = getNextDate(curRow.value?.startDate)
|
|
|
+ tableEditData.value.splice( curIndex.value + 1, 0, { isNew:true, startDate:netxtDay })
|
|
|
+}
|
|
|
+//获取连续的时间
|
|
|
+const getNextDate = (data)=>{
|
|
|
+ let dateString = data
|
|
|
+ // 将日期字符串转换为 Date 对象
|
|
|
+ let dateObject = new Date(dateString)
|
|
|
+ // 将日期加一天
|
|
|
+ dateObject.setDate(dateObject.getDate() + 1)
|
|
|
+ // 获取新日期的年、月、日
|
|
|
+ let year = dateObject.getFullYear()
|
|
|
+ let month = dateObject.getMonth() + 1 // 注意:月份从0开始,所以要加1
|
|
|
+ let day = dateObject.getDate()
|
|
|
+
|
|
|
+ // 将年、月、日格式化为字符串
|
|
|
+ let newDateString = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
|
|
|
|
|
|
+ // 输出结果
|
|
|
+ console.log(newDateString)
|
|
|
+ return newDateString
|
|
|
+}
|
|
|
+const delRow = (row, index)=>{
|
|
|
+ console.log(index, 'index')
|
|
|
+ tableEditData.value.splice(index, 1)
|
|
|
+ if ( tableEditData.value.length === 0) {
|
|
|
+ tableEditData.value.push({})
|
|
|
+ }
|
|
|
+}
|
|
|
//编辑的表格
|
|
|
const tableEditColumn = [
|
|
|
- { key: 'key1', name: '期号' },
|
|
|
- { key: 'key2', name: '年份' },
|
|
|
- { key: 'key3', name: '月份' },
|
|
|
- { key: 'key4', name: '开始日期' },
|
|
|
- { key: 'key5', name: '结束日期' },
|
|
|
- { key: 'key6', name: '报表打印日期' },
|
|
|
+ { key: 'periodNumber', name: '期号' },
|
|
|
+ { key: 'periodYear', name: '年份' },
|
|
|
+ { key: 'periodMonth', name: '月份' },
|
|
|
+ { key: 'startDate', name: '开始日期' },
|
|
|
+ { key: 'endDate', name: '结束日期' },
|
|
|
+ { key: 'formPrintDate', name: '报表打印日期' },
|
|
|
{ key: 'action', name: '操作', width: 80, align: 'center' },
|
|
|
]
|
|
|
-const tableEditData = ref([
|
|
|
- { key1: '11' },
|
|
|
- { key1: '222' },
|
|
|
-])
|
|
|
-
|
|
|
-const editModalSave = () => {
|
|
|
+const tableEditData = ref([])
|
|
|
+const tableEditLoading = ref(false)
|
|
|
+const getTableEditData = async () => {
|
|
|
+ tableEditLoading.value = true
|
|
|
+ const { error, code, data } = await mainApi.allPeriod({
|
|
|
+ ...searchForm.value,
|
|
|
+ contractId:contractId.value,
|
|
|
+ type:1,
|
|
|
+ })
|
|
|
+ tableEditLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ tableEditData.value = getArrValue(data)
|
|
|
+ if (tableEditData.value.length === 0) {
|
|
|
+ tableEditData.value.push({ isNew:true })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tableEditData.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+const saveLoading = ref(false)
|
|
|
+const editModalSave = async () => {
|
|
|
+ saveLoading.value = true
|
|
|
+ tableEditData.value.forEach(ele => {
|
|
|
+ ele.contractId = contractId.value
|
|
|
+ ele.projectId = projectId.value
|
|
|
+ })
|
|
|
+ const { error, code, msg } = await mainApi.edit({
|
|
|
+ list: tableEditData.value,
|
|
|
+ contractId:contractId.value,
|
|
|
+ projectId:projectId.value,
|
|
|
+ type:1,
|
|
|
+
|
|
|
+ })
|
|
|
+ //判断状态
|
|
|
+ saveLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success(msg)
|
|
|
+ }
|
|
|
+ getTableData()
|
|
|
editModalClose()
|
|
|
}
|
|
|
const editModalClose = () => {
|
|
|
editModalShow.value = false
|
|
|
}
|
|
|
+const changeStart = (val, row)=>{
|
|
|
+ if (val > row.endDate) {
|
|
|
+ window.$message.warning('开始时间不能晚于结束时间')
|
|
|
+ row.startDate = ''
|
|
|
+ }
|
|
|
+}
|
|
|
+const changeEnd = (val, row)=>{
|
|
|
+ if (val < row.startDate) {
|
|
|
+ window.$message.warning('结束时间不能早于开始时间')
|
|
|
+ row.endDate = ''
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|