|
@@ -137,12 +137,6 @@
|
|
|
@click="addDetailRecord"
|
|
|
>添加</el-button>
|
|
|
</el-dropdown-item>
|
|
|
- <el-dropdown-item>
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- :icon="Delete"
|
|
|
- >删除</el-button>
|
|
|
- </el-dropdown-item>
|
|
|
</el-dropdown-menu>
|
|
|
</template>
|
|
|
</el-dropdown>
|
|
@@ -232,7 +226,7 @@
|
|
|
type="primary"
|
|
|
size="small"
|
|
|
:icon="Delete"
|
|
|
- @click="costDelete(scope)"
|
|
|
+ @click="costDelete(scope.row)"
|
|
|
>删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -240,7 +234,7 @@
|
|
|
</el-row>
|
|
|
<el-drawer
|
|
|
v-model="editDrawerShow"
|
|
|
- title="编辑费用"
|
|
|
+ :title="drawerTitle"
|
|
|
width="40%"
|
|
|
>
|
|
|
<el-form
|
|
@@ -351,7 +345,7 @@
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
size="large"
|
|
|
- @click="editCost"
|
|
|
+ @click="changeCostList"
|
|
|
>确认</el-button>
|
|
|
</el-row>
|
|
|
|
|
@@ -365,8 +359,10 @@ import { ref, reactive, onMounted } from 'vue'
|
|
|
import { getAllUsers } from '@/api/user'
|
|
|
import { queryExpensesGenre } from '@/api/finance'
|
|
|
import { getAllProject } from '@/api/project'
|
|
|
-import { queryCostList } from '@/api/cost'
|
|
|
+import { queryCostList, updateCost } from '@/api/cost'
|
|
|
import { getDepByStart } from '@/api/department'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { deleteCost, createCost } from '@/api/cost'
|
|
|
defineOptions({
|
|
|
name: 'DetailList'
|
|
|
})
|
|
@@ -413,6 +409,10 @@ const editData = reactive({
|
|
|
remarks: '',
|
|
|
thenBalance: 0
|
|
|
})
|
|
|
+
|
|
|
+// 抽屉类型、标题
|
|
|
+const drawerType = ref('')
|
|
|
+const drawerTitle = ref('')
|
|
|
// 方法
|
|
|
onMounted(() => {
|
|
|
getUserList()
|
|
@@ -472,7 +472,6 @@ const getCostList = (nameId, typeID, itemId) => {
|
|
|
condition.genre = typeID
|
|
|
condition.projectId = itemId
|
|
|
queryCostList(condition).then(res => {
|
|
|
- console.log('费用列表', res.data)
|
|
|
if (res.code === 0) {
|
|
|
costList.length = 0
|
|
|
costList.push(...res.data.list)
|
|
@@ -481,26 +480,66 @@ const getCostList = (nameId, typeID, itemId) => {
|
|
|
}
|
|
|
const costEdit = (row) => {
|
|
|
editDrawerShow.value = true
|
|
|
- console.log(row)
|
|
|
- Object.assign(editData, row)
|
|
|
- // id: 0,
|
|
|
- // reimburser: 1,
|
|
|
- // departmentId: 1,
|
|
|
- // expenditureAmount: 0,
|
|
|
- // depositAmount: 0,
|
|
|
- // feeTime: '',
|
|
|
- // genre: 1,
|
|
|
- // projectId: 1,
|
|
|
- // expenseDetail: '',
|
|
|
- // remarks: '',
|
|
|
- // thenBalance: 0
|
|
|
+ drawerType.value = 'edit'
|
|
|
+ drawerTitle.value = '编辑费用'
|
|
|
+ editData.id = row.ID
|
|
|
+ editData.reimburser = row.reimburser
|
|
|
+ editData.departmentId = row.departmentId
|
|
|
+ editData.expenditureAmount = row.expenditureAmount
|
|
|
+ editData.depositAmount = row.depositAmount
|
|
|
+ editData.feeTime = row.feeTime
|
|
|
+ editData.genre = row.genre
|
|
|
+ editData.projectId = row.projectId
|
|
|
+ editData.expenseDetail = row.expenseDetail
|
|
|
+ editData.remarks = row.remarks
|
|
|
+ editData.thenBalance = row.thenBalance
|
|
|
}
|
|
|
-const costDelete = (scope) => {
|
|
|
- console.log(scope)
|
|
|
+const costDelete = (row) => {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '确定要删除此费用记录吗?',
|
|
|
+ '删除记录',
|
|
|
+ {
|
|
|
+ confirmButtonText: '删除',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ const data = {
|
|
|
+ id: row.ID
|
|
|
+ }
|
|
|
+ deleteCost(data).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ consultCostList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ ElMessage({
|
|
|
+ type: 'info',
|
|
|
+ message: '取消删除',
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
const addDetailRecord = () => {
|
|
|
- const test = [{}, {}, {}, {}, {}]
|
|
|
- costList.push(...test)
|
|
|
+ const initialData = {
|
|
|
+ id: 0,
|
|
|
+ reimburser: 1,
|
|
|
+ departmentId: 1,
|
|
|
+ expenditureAmount: 0,
|
|
|
+ depositAmount: 0,
|
|
|
+ feeTime: '',
|
|
|
+ genre: 1,
|
|
|
+ projectId: 1,
|
|
|
+ expenseDetail: '',
|
|
|
+ remarks: '',
|
|
|
+ thenBalance: 0
|
|
|
+ }
|
|
|
+ Object.assign(editData, initialData)
|
|
|
+ editDrawerShow.value = true
|
|
|
+ drawerType.value = 'add'
|
|
|
+ drawerTitle.value = '新增费用'
|
|
|
}
|
|
|
|
|
|
const clearPeopleSelect = () => {
|
|
@@ -534,9 +573,41 @@ const changeTimeType = (value) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const editCost = () => {
|
|
|
- console.log('支出金额', editData.expenditureAmount)
|
|
|
- console.log('支出金额', typeof editData.expenditureAmount)
|
|
|
+const changeCostList = () => {
|
|
|
+ for (const item in editData) {
|
|
|
+ if (item === 'thenBalance') {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if (editData[item] === '' || editData[item] === null) {
|
|
|
+ ElMessage({
|
|
|
+ message: '请将除余额以外的信息填写完整',
|
|
|
+ type: 'error',
|
|
|
+ showClose: true,
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ editData.thenBalance = parseFloat(editData.thenBalance)
|
|
|
+ editData.expenditureAmount = parseFloat(editData.expenditureAmount)
|
|
|
+ editData.depositAmount = parseFloat(editData.depositAmount)
|
|
|
+ if (drawerType.value === 'add') {
|
|
|
+ createCost(editData).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ editDrawerShow.value = false
|
|
|
+ consultCostList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ updateCost(editData).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ editDrawerShow.value = false
|
|
|
+ consultCostList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|