index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="page-container row-container">
  3. <section class="list-part-container" style="flex: 2">
  4. <!-- 搜索区域 -->
  5. <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
  6. <el-form-item class="section-title" label="辅助工序管理" />
  7. <el-form-item label="辅助工序名称:" prop="code">
  8. <el-input v-model="queryParams.name" placeholder="请输入辅助工序名称" clearable @keyup.enter="handleQuery"
  9. style="width: 160px;" />
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="info" icon="Search" @click="handleQuery">搜索</el-button>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="Plus" @click="handleAdd(null)"
  16. v-hasPermi="['business:auxiliaryProcess:add']">新增</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <!-- 列表区域 -->
  20. <div class="el-table-container">
  21. <div class="el-table-inner-container">
  22. <el-table v-loading="loading" :data="processList" border height="100%"
  23. @selection-change="handleSelectionChange">
  24. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  25. <el-table-column type="index" label="行号" width="50" align="center" />
  26. <el-table-column label="辅助工序名称" align="center" prop="name">
  27. <template #default="scope">
  28. <el-input v-if="scope.row.editStatus" placeholder="辅助工序名称" v-model="scope.row.name"
  29. style="width: 100%;" />
  30. <div v-else>{{ scope.row.name }}</div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="备注" align="center" prop="remark">
  34. <template #default="scope">
  35. <el-input v-if="scope.row.editStatus" placeholder="备注" v-model="scope.row.remark"
  36. style="width: 100%;" />
  37. <div v-else>{{ scope.row.remark }}</div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  41. <template #default="scope">
  42. <el-button v-if="!scope.row.editStatus" link type="warning" size="small" icon="Edit"
  43. @click="handleUpdate(scope.row)" v-hasPermi="['business:auxiliaryProcess:edit']">修改</el-button>
  44. <el-button v-else link type="success" size="small" icon="Check"
  45. @click="handleSave(scope.row)">保存</el-button>
  46. <el-button v-if="!scope.row.editStatus" link type="danger" size="small" icon="Delete"
  47. @click="handleDelete(scope.row)" v-hasPermi="['business:auxiliaryProcess:remove']">删除</el-button>
  48. <el-button v-else link type="info" size="small" icon="Close" @click="handleCancel(scope.row)"
  49. v-hasPermi="['business:auxiliaryProcess:remove']">取消</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. </div>
  54. </div>
  55. <pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
  56. @pagination="getList" />
  57. </section>
  58. </div>
  59. </template>
  60. <script setup name="Equipment">
  61. import { listProcess, delProcess, addProcess, updateProcess } from "@/api/business/auxiliaryProcess";
  62. const { proxy } = getCurrentInstance();
  63. const processList = ref([]);
  64. const loading = ref(true);
  65. const ids = ref([])
  66. const single = ref(true);
  67. const multiple = ref(true);
  68. const total = ref(0);
  69. /** 查询对象 */
  70. const queryParams = ref({
  71. pageNum: 1,
  72. pageSize: 10,
  73. code: null,
  74. name: null,
  75. status: null,
  76. })
  77. /*********************** 方法区 ****************************/
  78. /** 查询检查类别列表 */
  79. function getList() {
  80. loading.value = true;
  81. listProcess(queryParams.value).then(response => {
  82. processList.value = response.rows;
  83. total.value = response.total;
  84. loading.value = false;
  85. });
  86. }
  87. /** 搜索按钮操作 */
  88. function handleQuery() {
  89. queryParams.value.pageNum = 1;
  90. getList();
  91. }
  92. // 多选框选中数据
  93. function handleSelectionChange(selection) {
  94. ids.value = selection.map(item => item.id);
  95. single.value = selection.length != 1;
  96. multiple.value = !selection.length;
  97. }
  98. /** 新增按钮操作 */
  99. function handleAdd() {
  100. processList.value.push({ editStatus: true })
  101. }
  102. /** 修改按钮操作 */
  103. function handleUpdate(row) {
  104. row.editStatus = true
  105. }
  106. /** 删除按钮操作 */
  107. function handleDelete(row) {
  108. const _ids = row.id || ids.value;
  109. proxy.$modal.confirm('是否确认删除选中的数据项?').then(function () {
  110. return delProcess(_ids);
  111. }).then(() => {
  112. getList();
  113. proxy.$modal.msgSuccess("删除成功!");
  114. }).catch(() => { });
  115. }
  116. function handleSave(row) {
  117. if (row.id == null) {
  118. addProcess(row).then(afterSave)
  119. } else {
  120. updateProcess(row).then(afterSave)
  121. }
  122. }
  123. function afterSave(res) {
  124. if (res.code === 200) {
  125. getList()
  126. proxy.$modal.msgSuccess("保存成功!")
  127. } else {
  128. proxy.$modal.msgError("保存失败!")
  129. }
  130. }
  131. function handleCancel(row) {
  132. row.editStatus = false
  133. }
  134. getList();
  135. </script>
  136. <style scoped>
  137. :deep(.el-tree-node__label) {
  138. font-size: 14px !important;
  139. display: inline-block;
  140. width: 100%;
  141. }
  142. :deep(.el-tree-node__content) {
  143. height: 40px;
  144. border-bottom: 1px solid #ebeef5;
  145. padding: 8px 0;
  146. line-height: 23px;
  147. }
  148. .move-handle {
  149. cursor: move;
  150. background-color: #eee;
  151. }
  152. </style>