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
5.4 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
5 months ago
  1. <script setup lang="ts">
  2. import type { MatrixCraftQuery } from 'apis/matrixCraft'
  3. import { list as listMatrix } from 'apis/matrix'
  4. import { del, list } from 'apis/matrixCraft'
  5. import route2 from 'assets/images/route_horizontal.png'
  6. import route1 from 'assets/images/route_vertical.png'
  7. import FtButton from 'components/common/FTButton/index.vue'
  8. import Edit from 'components/martixCraft/Edit/index.vue'
  9. import { ElMessageBox } from 'element-plus'
  10. import { FtMessage } from 'libs/message'
  11. import { onMounted, ref } from 'vue'
  12. onMounted(() => {
  13. getList()
  14. getMatrixList()
  15. })
  16. const selectedData = ref<any[]>([])
  17. const handleSelectionChange = (val: any[]) => {
  18. console.log(val)
  19. selectedData.value = val
  20. }
  21. const tableData = ref([])
  22. const matrixList = ref<{ id: number, name: string }[]>([])
  23. const total = ref(0)
  24. const query = ref<MatrixCraftQuery>({
  25. pageNum: 1,
  26. pageSize: 10,
  27. matrixCraftName: undefined,
  28. matrixId: undefined,
  29. })
  30. const getMatrixList = async () => {
  31. const res = await listMatrix({ pageNum: 1, pageSize: 100, matrixName: '' })
  32. matrixList.value = res.list
  33. }
  34. const loading = ref(false)
  35. const getList = async () => {
  36. loading.value = true
  37. const res = await list(query.value)
  38. tableData.value = res.list
  39. total.value = res.total
  40. loading.value = false
  41. }
  42. const addVisible = ref(false)
  43. const addHandle = () => {
  44. formData.value = {}
  45. addVisible.value = true
  46. }
  47. const formData = ref({})
  48. const editHandle = () => {
  49. formData.value = selectedData.value[0]
  50. addVisible.value = true
  51. }
  52. const delHandle = async () => {
  53. const ids = selectedData.value.map((item: any) => item.id)
  54. ElMessageBox.confirm('确认删除?', '提示', {
  55. type: 'warning',
  56. confirmButtonText: '确定',
  57. cancelButtonText: '取消',
  58. showCancelButton: true,
  59. showClose: false,
  60. closeOnClickModal: false,
  61. closeOnPressEscape: false,
  62. closeOnHashChange: false,
  63. }).then(async () => {
  64. await del(ids.join(','))
  65. FtMessage.success('删除成功')
  66. await getList()
  67. })
  68. }
  69. const pageChange = (pageNum: number, pageSize: number) => {
  70. query.value.pageNum = pageNum
  71. query.value.pageSize = pageSize
  72. getList()
  73. }
  74. const inputChange = () => {
  75. query.value.pageNum = 1
  76. query.value.pageSize = 10
  77. getList()
  78. }
  79. const ok = () => {
  80. addVisible.value = false
  81. getList()
  82. }
  83. </script>
  84. <template>
  85. <div>
  86. <el-row class="search-box">
  87. <el-col :span="12">
  88. <el-input v-model="query.matrixCraftName" class="my-input" placeholder="请输入工艺名称" clearable @input="inputChange" />
  89. <el-select v-model="query.matrixId" class="my-select" placeholder="请选择基质" clearable @change="inputChange">
  90. <el-option v-for="item in matrixList" :key="item.id" :label="item.name" :value="item.id" />
  91. </el-select>
  92. </el-col>
  93. <el-col :span="12">
  94. <div style="float: right">
  95. <FtButton type="primary" @click="addHandle">
  96. 新增
  97. </FtButton>
  98. <FtButton :disabled="selectedData.length !== 1" @click="editHandle">
  99. 编辑
  100. </FtButton>
  101. <FtButton :disabled="selectedData.length === 0" @click="delHandle">
  102. 删除
  103. </FtButton>
  104. </div>
  105. </el-col>
  106. </el-row>
  107. <div class="table-box">
  108. <el-table
  109. v-loading="loading"
  110. :data="tableData"
  111. header-row-class-name="table-header"
  112. height="100%"
  113. @selection-change="handleSelectionChange"
  114. >
  115. <el-table-column type="selection" width="55" />
  116. <el-table-column prop="matrixName" label="基质名称">
  117. <template #default="scope">
  118. <div class="scope-box">
  119. {{ matrixList.find(item => item.id === scope.row.matrixId)?.name }}
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="name" label="工艺名称" />
  124. <el-table-column prop="matrixPathType" label="喷涂路线">
  125. <template #default="scope">
  126. <div class="scope-box">
  127. <img v-show="scope.row.routeType === 'horizontal'" :src="route1" width="20px" height="20px" alt="icon">
  128. <img v-show="scope.row.routeType === 'vertical'" :src="route2" width="20px" height="20px" alt="icon">
  129. <img v-show="scope.row.routeType === 'grid'" :src="route2" width="20px" height="20px" alt="icon">
  130. </div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="motorZHeight" label="喷涂高度" />
  134. <el-table-column prop="gasPressure" label="氮气气压" />
  135. <el-table-column prop="volume" label="基质流速" />
  136. <el-table-column prop="highVoltageValue" label="电压" />
  137. <el-table-column prop="movingSpeed" label="移速" />
  138. <el-table-column prop="spacing" label="行间距" />
  139. <el-table-column prop="times" label="喷涂遍数" />
  140. </el-table>
  141. </div>
  142. <div class="table-footer">
  143. <el-pagination size="large" :total background layout="prev, pager, next,total" @change="pageChange" />
  144. </div>
  145. <Edit v-if="addVisible" :matrix-list :form-data @ok="ok" @cancel="addVisible = false" />
  146. </div>
  147. </template>
  148. <style scoped lang="scss">
  149. .table-header {
  150. background: #E8ECF7;
  151. }
  152. .my-input {
  153. width: 400px;
  154. margin-right: 20px;
  155. }
  156. :deep(.el-input__inner)::placeholder {
  157. color: #a8abb2;
  158. font-size: 40px;
  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>