Contract.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <script setup lang="ts">
  2. import { GlobalStore } from '@/stores/index'
  3. import { ref, reactive, nextTick } from 'vue'
  4. import ContractForm from './ContractForm.vue'
  5. import { useRouter } from 'vue-router'
  6. import { fnMd5 } from '@/utils/common'
  7. import { ElMessageBox, ElMessage } from 'element-plus'
  8. import TableBase from '@/components/TableBase/index.vue'
  9. import { Edit, Delete, Finished, View } from '@element-plus/icons-vue'
  10. import type { ColumnProps } from '@/components/TableBase/interface/index'
  11. import { Storehouse_Contract_List, Storehouse_Contract_Del } from '@/api/storehouse/index'
  12. const router = useRouter()
  13. const globalStore = GlobalStore()
  14. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  15. const ContractFormRef = ref<InstanceType<typeof ContractForm> | null>(null)
  16. const columns: ColumnProps[] = [
  17. { type: 'index', label: '序号', width: 80 },
  18. { prop: 'T_number', label: '合同编号' },
  19. { prop: 'T_customer', label: '客户名称' },
  20. { prop: 'T_State', label: '状态', name: 'T_State' },
  21. { prop: 'T_out', label: '是否出库', name: 'T_out' },
  22. { prop: 'T_date', label: '更新时间' },
  23. { prop: 'operation', label: '操作', width: 260, fixed: 'right' }
  24. ]
  25. const openContractFormDrawer = (type: string, row?: any) => {
  26. ContractFormRef.value?.openDrawer(type, row)
  27. }
  28. const updateOnTableList = () => TableRef.value?.getTableList()
  29. // 审核
  30. const processContract = (id: string) => {
  31. router.push({ name: 'ContractDetail', params: { id, type: fnMd5('contract') } })
  32. }
  33. // 删除
  34. const UserDelete = (row: any) => {
  35. ElMessageBox.confirm('您确定要删除该销售合同吗?', '警告', {
  36. confirmButtonText: '确定',
  37. cancelButtonText: '取消',
  38. type: 'warning'
  39. })
  40. .then(async () => {
  41. const res: any = await Storehouse_Contract_Del({ User_tokey: globalStore.GET_User_tokey, T_number: row.T_number })
  42. if (res.Code === 200) {
  43. ElMessage.success('删除成功!')
  44. nextTick(() => {
  45. TableRef.value?.getTableList()
  46. })
  47. }
  48. })
  49. .catch(() => {
  50. ElMessage.warning('取消成功!')
  51. })
  52. }
  53. // 搜索
  54. const options = reactive([
  55. { name: '已通过', id: 1 },
  56. { name: '未通过', id: 2 },
  57. { name: '待审核', id: 3 }
  58. ])
  59. const initParam = reactive({
  60. User_tokey: globalStore.GET_User_tokey,
  61. T_name: '',
  62. T_state: ''
  63. })
  64. const searchHandle = () => {
  65. TableRef.value?.searchTable()
  66. }
  67. </script>
  68. <template>
  69. <div class="contract">
  70. <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_Contract_List" :initParam="initParam">
  71. <template #table-header>
  72. <div class="input-suffix">
  73. <el-row :gutter="20" style="margin-bottom: 0">
  74. <el-col :xl="6" :lg="8" :md="10">
  75. <span class="inline-flex items-center">合同编号:</span>
  76. <el-input
  77. v-model="initParam.T_name"
  78. type="text"
  79. class="w-50 m-2"
  80. placeholder="按产品名称搜索"
  81. @change="searchHandle"
  82. />
  83. </el-col>
  84. <el-col :xl="10" :md="12">
  85. <span class="inline-flex items-center">状态:</span>
  86. <el-select v-model="initParam.T_state" class="w-50" clearable placeholder="请选择状态~">
  87. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
  88. </el-select>
  89. <el-button type="primary" @click="searchHandle">搜索</el-button>
  90. </el-col>
  91. <el-col :xl="6" :md="2" class="btn"
  92. ><el-button type="primary" @click="openContractFormDrawer('new')">添加</el-button></el-col
  93. >
  94. </el-row>
  95. </div>
  96. </template>
  97. <template #T_State="{ row }">
  98. <el-tag v-if="row.T_State === 1" type="success" effect="dark"> 已通过 </el-tag>
  99. <el-tag v-else-if="row.T_State === 2" type="warning" effect="dark"> 未通过 </el-tag>
  100. <el-tag v-else type="danger" effect="dark"> 待审核 </el-tag>
  101. </template>
  102. <template #T_out="{ row }">
  103. <el-tag v-if="row.T_out === 2 || row.T_out === 3" type="success" effect="dark">
  104. {{ row.T_out === 2 ? '已出库' : '已全部出库' }}
  105. </el-tag>
  106. <el-tag v-else-if="row.T_out === 1" type="warning" effect="dark"> 未出库 </el-tag>
  107. <el-tag v-else type="danger" effect="dark"> --- </el-tag>
  108. </template>
  109. <template #right="{ row }">
  110. <el-button
  111. :disabled="row.T_State !== 3"
  112. link
  113. type="warning"
  114. size="small"
  115. :icon="Finished"
  116. @click="processContract(row.T_number)"
  117. >审核</el-button
  118. >
  119. <el-button link type="primary" size="small" :icon="Edit" @click="openContractFormDrawer('edit', row)"
  120. >编辑</el-button
  121. >
  122. <el-button link type="success" size="small" :icon="View" @click="processContract(row.T_number)">详情</el-button>
  123. <el-button link type="danger" size="small" :icon="Delete" @click="UserDelete(row)">删除</el-button>
  124. </template>
  125. </TableBase>
  126. <ContractForm ref="ContractFormRef" @onTableList="updateOnTableList" />
  127. </div>
  128. </template>
  129. <style scoped lang="scss">
  130. .contract {
  131. :deep(.el-drawer__header) {
  132. margin-bottom: 0;
  133. }
  134. .input-suffix {
  135. width: 100%;
  136. .inline-flex {
  137. white-space: nowrap;
  138. }
  139. .btn {
  140. display: flex;
  141. justify-content: end;
  142. }
  143. .w-50 {
  144. width: 12.5rem;
  145. }
  146. }
  147. }
  148. </style>