上传分包合同

This commit is contained in:
mkm 2023-12-09 17:17:14 +08:00
parent 64e8e773f5
commit 1eff1a2ba9
3 changed files with 386 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 分包合同列表
export function apiSubcontractingContractLists(params: any) {
return request.get({ url: '/contract.subcontracting_contract/lists', params })
}
// 添加分包合同
export function apiSubcontractingContractAdd(params: any) {
return request.post({ url: '/contract.subcontracting_contract/add', params })
}
// 编辑分包合同
export function apiSubcontractingContractEdit(params: any) {
return request.post({ url: '/contract.subcontracting_contract/edit', params })
}
// 删除分包合同
export function apiSubcontractingContractDelete(params: any) {
return request.post({ url: '/contract.subcontracting_contract/delete', params })
}
// 分包合同详情
export function apiSubcontractingContractDetail(params: any) {
return request.get({ url: '/contract.subcontracting_contract/detail', params })
}

View File

@ -0,0 +1,204 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="组织id" prop="org_id">
<el-input v-model="formData.org_id" clearable placeholder="请输入组织id" />
</el-form-item>
<el-form-item label="部门id" prop="department_id">
<el-input v-model="formData.department_id" clearable placeholder="请输入部门id" />
</el-form-item>
<el-form-item label="项目id" prop="project_id">
<el-input v-model="formData.project_id" clearable placeholder="请输入项目id" />
</el-form-item>
<el-form-item label="合同编号" prop="contract_no">
<el-input v-model="formData.contract_no" clearable placeholder="请输入合同编号" />
</el-form-item>
<el-form-item label="合同名称" prop="contract_name">
<el-input v-model="formData.contract_name" clearable placeholder="请输入合同名称" />
</el-form-item>
<el-form-item label="供应商id" prop="supplier_id">
<el-input v-model="formData.supplier_id" clearable placeholder="请输入供应商id" />
</el-form-item>
<el-form-item label="合同类型" prop="contract_type">
<el-radio-group v-model="formData.contract_type" placeholder="请选择合同类型">
<el-radio
v-for="(item, index) in dictData.contract_type"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="签订日期" prop="signing_date">
<el-date-picker
class="flex-1 !flex"
v-model="formData.signing_date"
clearable
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择签订日期">
</el-date-picker>
</el-form-item>
<el-form-item label="付款方式" prop="pay_type">
<el-input v-model="formData.pay_type" clearable placeholder="请输入付款方式" />
</el-form-item>
<el-form-item label="账期" prop="account_period">
<el-radio-group v-model="formData.account_period" placeholder="请选择账期">
<el-radio
v-for="(item, index) in dictData.account_period"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="合同金额" prop="amount">
<el-input v-model="formData.amount" clearable placeholder="请输入合同金额" />
</el-form-item>
<el-form-item label="金额大写" prop="amount_daxie">
<el-input v-model="formData.amount_daxie" clearable placeholder="请输入金额大写" />
</el-form-item>
<el-form-item label="税率" prop="tax_rate">
<el-select class="flex-1" v-model="formData.tax_rate" clearable placeholder="请选择税率">
<el-option
v-for="(item, index) in dictData.tax_rate"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="不含税金额" prop="amount_excluding_tax">
<el-input v-model="formData.amount_excluding_tax" clearable placeholder="请输入不含税金额" />
</el-form-item>
<el-form-item label="质保金比例" prop="retention_money">
<el-input v-model="formData.retention_money" clearable placeholder="请输入质保金比例" />
</el-form-item>
<el-form-item label="质保金" prop="retention_money_rate">
<el-input v-model="formData.retention_money_rate" clearable placeholder="请输入质保金" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" clearable placeholder="请输入备注" />
</el-form-item>
<el-form-item label="件" prop="annex">
<el-input v-model="formData.annex" clearable placeholder="请输入件" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="subcontractingContractEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiSubcontractingContractAdd, apiSubcontractingContractEdit, apiSubcontractingContractDetail } from '@/api/subcontracting_contract'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑分包合同' : '新增分包合同'
})
//
const formData = reactive({
id: '',
org_id: '',
department_id: '',
project_id: '',
contract_no: '',
contract_name: '',
supplier_id: '',
contract_type: '',
signing_date: '',
pay_type: '',
account_period: '',
amount: '',
amount_daxie: '',
tax_rate: '',
amount_excluding_tax: '',
retention_money: '',
retention_money_rate: '',
remark: '',
annex: '',
})
//
const formRules = reactive<any>({
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiSubcontractingContractDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiSubcontractingContractEdit(data)
: await apiSubcontractingContractAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,156 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="部门id" prop="department_id">
<el-input class="w-[280px]" v-model="queryParams.department_id" clearable placeholder="请输入部门id" />
</el-form-item>
<el-form-item label="合同名称" prop="contract_name">
<el-input class="w-[280px]" v-model="queryParams.contract_name" clearable placeholder="请输入合同名称" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['contract.subcontracting_contract/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['contract.subcontracting_contract/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="组织id" prop="org_id" show-overflow-tooltip />
<el-table-column label="部门id" prop="department_id" show-overflow-tooltip />
<el-table-column label="项目id" prop="project_id" show-overflow-tooltip />
<el-table-column label="合同编号" prop="contract_no" show-overflow-tooltip />
<el-table-column label="合同名称" prop="contract_name" show-overflow-tooltip />
<el-table-column label="供应商id" prop="supplier_id" show-overflow-tooltip />
<el-table-column label="合同类型" prop="contract_type">
<template #default="{ row }">
<dict-value :options="dictData.contract_type" :value="row.contract_type" />
</template>
</el-table-column>
<el-table-column label="签订日期" prop="signing_date" show-overflow-tooltip />
<el-table-column label="付款方式" prop="pay_type" show-overflow-tooltip />
<el-table-column label="账期" prop="account_period">
<template #default="{ row }">
<dict-value :options="dictData.account_period" :value="row.account_period" />
</template>
</el-table-column>
<el-table-column label="合同金额" prop="amount" show-overflow-tooltip />
<el-table-column label="金额大写" prop="amount_daxie" show-overflow-tooltip />
<el-table-column label="税率" prop="tax_rate">
<template #default="{ row }">
<dict-value :options="dictData.tax_rate" :value="row.tax_rate" />
</template>
</el-table-column>
<el-table-column label="不含税金额" prop="amount_excluding_tax" show-overflow-tooltip />
<el-table-column label="质保金比例" prop="retention_money" show-overflow-tooltip />
<el-table-column label="质保金" prop="retention_money_rate" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['contract.subcontracting_contract/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['contract.subcontracting_contract/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="subcontractingContractLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiSubcontractingContractLists, apiSubcontractingContractDelete } from '@/api/subcontracting_contract'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
department_id: '',
contract_name: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('contract_type,account_period,tax_rate')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiSubcontractingContractLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiSubcontractingContractDelete({ id })
getLists()
}
getLists()
</script>