Contract.vue 4.7 KB

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