Recoveries.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <script setup lang="ts">
  2. import {
  3. Storehouse_VerifyContract_Add_Customer,
  4. Storehouse_VerifyContract_Recover_List,
  5. Storehouse_VerifyContract_Update_Customer
  6. } from '@/api/storehouse/index'
  7. import { useRouter } from 'vue-router'
  8. import { ElMessage } from 'element-plus'
  9. import { ref, reactive, nextTick ,defineAsyncComponent} from 'vue'
  10. import Drawer from '@/components/Drawer/index.vue'
  11. import TableBase from '@/components/TableBase/index.vue'
  12. import { Edit, View } from '@element-plus/icons-vue'
  13. import type { ColumnProps } from '@/components/TableBase/interface/index'
  14. import type { FormInstance, FormRules } from 'element-plus'
  15. import { useTablePublic } from '@/hooks/useTablePublic'
  16. import { fnMd5 } from '@/utils/common'
  17. const isNew = ref(true)
  18. const router = useRouter()
  19. const ruleFormRef = ref<FormInstance>()
  20. const drawerRef = ref<InstanceType<typeof Drawer> | null>(null)
  21. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  22. const { resetForm, globalStore, searchOnTableList, updateOnTableList } = useTablePublic()
  23. const columns: ColumnProps[] = [
  24. { type: 'index', label: '序号', width: 80 },
  25. { prop: 'T_number', label: '合同编号' },
  26. { prop: 'T_customer', label: '客户名称' },
  27. { prop: 'T_type', label: '合同类型', name: 'T_type'},
  28. { prop: 'T_money', label: '合同总金额' },
  29. { prop: 'T_discount', label: '优惠金额' },
  30. { prop: 'T_recoveries_money', label: '回款金额' },
  31. { prop: 'T_invoice_money', label: '开票金额' },
  32. { prop: 'operation', label: '操作', width: 260, fixed: 'right' }
  33. ]
  34. const options1 = reactive([
  35. { name: '未回款', id: 1 },
  36. { name: '部分回款', id: 2 },
  37. { name: '全部回款', id: 3 },
  38. ])
  39. const options2 = reactive([
  40. { name: '未开票', id: 1 },
  41. { name: '部分开票', id: 2 },
  42. { name: '全部开票', id: 3 },
  43. ])
  44. const ContractFormRef = ref<InstanceType<typeof ContractForm> | null>(null)
  45. const VerifyFormRef = ref<InstanceType<typeof VerifyForm> | null>(null)
  46. //编辑弹出
  47. const openContractFormDrawer = (type: string, row?: any) => {
  48. if (row.T_type==1) {
  49. ContractFormRef.value?.openDrawer(type, row)//12544
  50. } else {
  51. VerifyFormRef.value?.openDrawer(type, row)
  52. }
  53. }
  54. // const processContract = (id: string) => router.push({ name: 'VerifyContractDetail', params: { id } })
  55. const ContractForm = defineAsyncComponent({
  56. loader: () => import(/*webpackChunkName: 'ContractForm'*/ './ContractForm.vue'),
  57. delay: 500,
  58. timeout: 3000,
  59. suspensible: true
  60. })
  61. const VerifyForm = defineAsyncComponent({
  62. loader: () => import(/*webpackChunkName: 'ContractForm'*/ './VerifyForm.vue'),
  63. delay: 500,
  64. timeout: 3000,
  65. suspensible: true
  66. })
  67. const initParam = reactive({
  68. User_tokey: globalStore.GET_User_tokey,
  69. T_name: '',
  70. T_recoveries_state: '',//回款状态
  71. T_invoice_state:''//开票状态
  72. })
  73. // const openContract = (type: string, row?: any) => {
  74. // isNew.value = type === 'new' ? true : false
  75. // if (type === 'edit') {
  76. // form.value = { ...row }
  77. // }
  78. // drawerRef.value?.openDrawer()
  79. // }
  80. //编辑弹出
  81. const processContract = (id: string) => router.push({ name: 'ContractDetail', params: { id, type: fnMd5('contract') } })
  82. const callbackDrawer = (done: () => void) => {
  83. resetForm(ruleFormRef.value)
  84. done()
  85. }
  86. const form = ref({
  87. T_customer: '',
  88. T_customer_id: ''
  89. })
  90. const rules = reactive<FormRules>({
  91. T_customer: [{ required: true, message: '请输入客户名称', trigger: 'blur' }]
  92. })
  93. const AddContract = (formEl: FormInstance | undefined) => {
  94. if (!formEl) return
  95. formEl.validate(async valid => {
  96. if (valid) {
  97. let res: any = {}
  98. if (isNew.value) {
  99. res = await Storehouse_VerifyContract_Add_Customer({ User_tokey: globalStore.GET_User_tokey, ...form.value })
  100. } else {
  101. res = await Storehouse_VerifyContract_Update_Customer({ User_tokey: globalStore.GET_User_tokey, ...form.value })
  102. }
  103. if (res.Code === 200) {
  104. ElMessage.success('添加客户成功!!')
  105. nextTick(() => {
  106. updateOnTableList(TableRef.value)
  107. isNew.value = true
  108. resetForm(ruleFormRef.value)
  109. drawerRef.value?.closeDrawer()
  110. })
  111. }
  112. } else {
  113. return false
  114. }
  115. })
  116. }
  117. </script>
  118. <template>
  119. <div class="verify-contract">
  120. <TableBase
  121. ref="TableRef"
  122. :columns="columns"
  123. :requestApi="Storehouse_VerifyContract_Recover_List"
  124. :initParam="initParam"
  125. >
  126. <template #table-header>
  127. <el-row :gutter="20" style="margin-bottom: 0" class="input-suffix">
  128. <el-col :xl="6" :lg="6" :md="6" class="d-flex">
  129. <span class="inline-flex items-center">合同编号:</span>
  130. <el-input
  131. v-model="initParam.T_name"
  132. type="text"
  133. class="w-50 m-2"
  134. placeholder="按编号搜索"
  135. @change="searchOnTableList(TableRef)"
  136. />
  137. </el-col>
  138. <el-col :xl="6" :lg="6" :md="6" class="d-flex">
  139. <span class="inline-flex items-center">回款状态:</span>
  140. <el-select v-model="initParam.T_recoveries_state" class="w-50" clearable placeholder="请选择">
  141. <el-option v-for="item in options1" :key="item.id" :label="item.name" :value="item.id" />
  142. </el-select>
  143. </el-col>
  144. <el-col :xl="6" :lg="6" :md="6" class="d-flex">
  145. <span class="inline-flex items-center">开票状态:</span>
  146. <el-select v-model="initParam.T_invoice_state" class="w-50" clearable placeholder="请选择">
  147. <el-option v-for="item in options2" :key="item.id" :label="item.name" :value="item.id" />
  148. </el-select>
  149. <el-button type="primary" @click="searchOnTableList(TableRef)">搜索</el-button>
  150. </el-col>
  151. <!-- <el-col :xl="6" :md="2" :offset="4" class="btn">
  152. <el-button type="primary" @click="openContract('new')">添加</el-button>
  153. </el-col> -->
  154. </el-row>
  155. </template>
  156. <template #T_type="{ row }">
  157. <el-tag :type="row.T_type==1?'':'success'" effect="dark"> {{row.T_type==1?'销售合同':row.T_type==2?'验证合同':'-'}} </el-tag>
  158. </template>
  159. <template #right="{ row }">
  160. <el-button link type="primary" size="small" :icon="Edit" @click="openContractFormDrawer('edit', row)">编辑</el-button>
  161. <!-- <el-button link type="success" size="small" :icon="View" @click="processContract(row.T_number)">明细</el-button> -->
  162. </template>
  163. </TableBase>
  164. <Drawer ref="drawerRef" :handleClose="callbackDrawer">
  165. <template #header="{ params }">
  166. <h4 :id="params.titleId" :class="params.titleClass">{{ isNew ? '添加' : '编辑' }} - 客户名称</h4>
  167. </template>
  168. <el-form ref="ruleFormRef" :model="form" :rules="rules">
  169. <el-form-item label="客户名称:" label-width="100px" prop="T_customer">
  170. <el-input v-model="form.T_customer" type="text" autocomplete="off" placeholder="请输入仓库名称" />
  171. </el-form-item>
  172. <el-form-item label-width="100px">
  173. <el-button v-if="isNew" color="#626aef" @click="AddContract(ruleFormRef)">提交</el-button>
  174. <el-button v-else color="#626aef" @click="AddContract(ruleFormRef)">修改</el-button>
  175. </el-form-item>
  176. </el-form>
  177. </Drawer>
  178. <ContractForm ref="ContractFormRef" @onTableList="updateOnTableList(TableRef)" />
  179. <VerifyForm ref="VerifyFormRef" @onTableList="updateOnTableList(TableRef)" :verify_customer_id="customer_id" />
  180. </div>
  181. </template>
  182. <style scoped lang="scss">
  183. @import '@/styles/var.scss';
  184. .verify-contract {
  185. @include f-direction;
  186. :deep(.el-drawer__header) {
  187. margin-bottom: 0;
  188. }
  189. .input-suffix {
  190. width: 100%;
  191. .inline-flex {
  192. white-space: nowrap;
  193. }
  194. .btn {
  195. display: flex;
  196. justify-content: end;
  197. }
  198. .w-50 {
  199. flex: 0 0 50%;
  200. }
  201. }
  202. }
  203. </style>