You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.3 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <script setup lang="ts">
  2. import type { MatrixQuery } from 'apis/matrix'
  3. import { del, list as listMatrix } from 'apis/matrix'
  4. import FtButton from 'components/common/FTButton/index.vue'
  5. import Edit from 'components/martix/Edit/index.vue'
  6. import { ElMessageBox } from 'element-plus'
  7. import { FtMessage } from 'libs/message'
  8. import { onMounted, ref } from 'vue'
  9. onMounted(() => {
  10. getList()
  11. })
  12. const tableData = ref([])
  13. const total = ref(0)
  14. const query = ref<MatrixQuery>({
  15. pageNum: 1,
  16. pageSize: 10,
  17. matrixName: undefined,
  18. })
  19. const loading = ref(false)
  20. const getList = async () => {
  21. loading.value = true
  22. const res = await listMatrix(query.value)
  23. tableData.value = res.list
  24. total.value = res.total
  25. loading.value = false
  26. }
  27. const addVisible = ref(false)
  28. const formData = ref({})
  29. const addHandle = () => {
  30. formData.value = {}
  31. addVisible.value = true
  32. }
  33. const pageChange = (pageNum: number, pageSize: number) => {
  34. query.value.pageNum = pageNum
  35. query.value.pageSize = pageSize
  36. getList()
  37. }
  38. const inputChange = () => {
  39. query.value.pageNum = 1
  40. query.value.pageSize = 10
  41. getList()
  42. }
  43. const ok = () => {
  44. addVisible.value = false
  45. getList()
  46. }
  47. const selectedData = ref<any[]>([])
  48. const handleSelectionChange = (val: any[]) => {
  49. console.log(val)
  50. selectedData.value = val
  51. }
  52. const editHandle = () => {
  53. formData.value = selectedData.value[0]
  54. addVisible.value = true
  55. }
  56. const delHandle = async () => {
  57. const ids = selectedData.value.map((item: any) => item.id)
  58. ElMessageBox.confirm('确认删除?', '提示', {
  59. type: 'warning',
  60. confirmButtonText: '确定',
  61. cancelButtonText: '取消',
  62. showCancelButton: true,
  63. showClose: false,
  64. closeOnClickModal: false,
  65. closeOnPressEscape: false,
  66. closeOnHashChange: false,
  67. }).then(async () => {
  68. const res = await del(ids.join(','))
  69. if (res.matrixName?.length) {
  70. FtMessage.error(`基质: ${res.matrixName.join(',')}已绑定工艺, 无法删除`)
  71. return
  72. }
  73. FtMessage.success('删除成功')
  74. await getList()
  75. })
  76. }
  77. </script>
  78. <template>
  79. <div>
  80. <el-row class="search-box">
  81. <el-col :span="12">
  82. <el-input v-model="query.matrixName" class="my-input" placeholder="请输入基质名称" clearable @input="inputChange" />
  83. </el-col>
  84. <el-col :span="12">
  85. <div style="float: right">
  86. <FtButton type="primary" @click="addHandle">
  87. 新增
  88. </FtButton>
  89. <FtButton :disabled="selectedData.length !== 1" @click="editHandle">
  90. 编辑
  91. </FtButton>
  92. <FtButton :disabled="selectedData.length === 0" @click="delHandle">
  93. 删除
  94. </FtButton>
  95. </div>
  96. </el-col>
  97. </el-row>
  98. <div class="table-box">
  99. <el-table v-loading="loading" :data="tableData" header-row-class-name="table-header" height="100%" @selection-change="handleSelectionChange">
  100. <el-table-column type="selection" width="55" />
  101. <el-table-column prop="name" label="基质名称" />
  102. </el-table>
  103. </div>
  104. <div class="table-footer">
  105. <el-pagination size="large" background layout="prev, pager, next, total" :total @change="pageChange" />
  106. </div>
  107. <Edit v-if="addVisible" :form-data @ok="ok" @cancel="addVisible = false" />
  108. </div>
  109. </template>
  110. <style scoped lang="scss">
  111. .table-header {
  112. background: #E8ECF7;
  113. }
  114. .my-input {
  115. height: 100px;
  116. width: 400px;
  117. margin-right: 20px;
  118. background: #E8ECF7;
  119. border: 0;
  120. .el-input__wrapper {
  121. background: #E8ECF7;
  122. border: 0;
  123. .el-input__inner {
  124. height: calc(100% - 2px);
  125. }
  126. }
  127. }
  128. :deep(.el-input__inner)::placeholder {
  129. color: #a8abb2;
  130. font-size: 40px;
  131. }
  132. .my-select {
  133. width: 400px;
  134. .el-select__input {
  135. height: 80px !important;
  136. }
  137. .el-select__wrapper {
  138. min-height: 80px;
  139. background: #E8ECF7;
  140. border: 0;
  141. font-size: 40px;
  142. line-height:40px;
  143. }
  144. .el-select__placeholder {
  145. color: #0349A8;
  146. font-weight: 500;
  147. }
  148. .el-select-dropdown__item {
  149. height: 80px;
  150. line-height: 40px;
  151. padding: 20px;
  152. font-size: 40px;
  153. }
  154. .el-select-dropdown__empty {
  155. font-size: 40px;
  156. line-height: 40px;
  157. padding: 20px;
  158. }
  159. }
  160. .search-box {
  161. height: 120px;
  162. }
  163. .table-footer {
  164. height: 100px;
  165. display: flex;
  166. justify-content: flex-end;
  167. }
  168. .table-box {
  169. height: calc(100% - 120px - 100px);
  170. }
  171. </style>