华西海圻ELN前端工程
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.

179 lines
5.3 KiB

  1. <template>
  2. <div class="app-container template-page">
  3. <el-form :model="searchForm" ref="searchForm" :inline="true">
  4. <el-form-item label="编号:" prop="sn">
  5. <el-input v-model="searchForm.sn" :placeholder="$t('form.placeholderInput')" clearable style="width: 150px"
  6. @keyup.enter.native="search" />
  7. </el-form-item>
  8. <el-form-item label="名称:" prop="name">
  9. <el-input v-model="searchForm.name" :placeholder="$t('form.placeholderInput')" clearable style="width: 150px"
  10. @keyup.enter.native="search" />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="search">{{ $t('form.search') }}</el-button>
  14. <el-button icon="el-icon-refresh" @click="reset">{{ $t('form.reset') }}</el-button>
  15. <el-button type="primary" plain icon="el-icon-plus" @click="edit(null)">新增</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-table v-loading="loading" :data="list">
  19. <el-table-column label="id" align="center" prop="id" />
  20. <el-table-column label="编号" align="center" prop="sn" />
  21. <el-table-column label="名称" align="center" prop="name" />
  22. <el-table-column label="创建时间" align="center" prop="createTime" />
  23. <el-table-column :label="$t('form.operate')" fixed="right" align="center" width="100">
  24. <template slot-scope="scope">
  25. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  26. <el-button type="text" @click="del(scope.row)">删除</el-button>
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
  31. @pagination="getList" />
  32. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="infoDialog.title" :visible.sync="infoDialog.visible" width="800px"
  33. append-to-body>
  34. <el-form ref="infoDialogForm" :model="infoDialog.formData" :rules="infoDialog.rules" label-width="180px">
  35. <el-row>
  36. <el-col :span="24">
  37. <el-form-item label="编号:" prop="sn">
  38. <el-input v-model="infoDialog.formData.sn" />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="24">
  42. <el-form-item label="名称:" prop="name">
  43. <el-input v-model="infoDialog.formData.name" />
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </el-form>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="save"> </el-button>
  50. <el-button @click="infoDialog.visible = false"> </el-button>
  51. </div>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script>
  56. import { step_list, step_info, step_save, step_delete } from "@/api/business/step/step";
  57. const EmptyDialogData = {
  58. id: '',
  59. name: '',
  60. sn: '',
  61. }
  62. export default {
  63. name: "StepPage",
  64. props: {
  65. },
  66. components: {
  67. },
  68. computed: {
  69. },
  70. filters: {
  71. },
  72. data() {
  73. return {
  74. searchForm: {
  75. pageNum: 1,
  76. pageSize: 10,
  77. sn: '',
  78. name: '',
  79. },
  80. loading: true,
  81. total: 0,
  82. list: [],
  83. infoDialog: {
  84. title: '',
  85. visible: false,
  86. formData: {},
  87. rules: {
  88. sn: [
  89. { required: true, message:'请输入', trigger: "blur" }
  90. ],
  91. name: [
  92. { required: true, message:'请输入', trigger: "blur" }
  93. ],
  94. },
  95. },
  96. };
  97. },
  98. created() {
  99. this.getList();
  100. },
  101. methods: {
  102. getList() {
  103. this.loading = true;
  104. step_list(this.searchForm).then(response => {
  105. this.list = response.rows;
  106. this.total = response.total;
  107. this.loading = false;
  108. });
  109. },
  110. search() {
  111. this.searchForm.pageNum = 1;
  112. this.getList();
  113. },
  114. reset() {
  115. this.searchForm = {
  116. pageNum: 1,
  117. pageSize: 10,
  118. sn: '',
  119. name: '',
  120. }
  121. this.search()
  122. },
  123. edit(row) {
  124. this.$refs['infoDialogForm'] && this.$refs['infoDialogForm'].resetFields()
  125. this.infoDialog.title = '新增'
  126. this.infoDialog.formData = _.merge({}, EmptyDialogData)
  127. if (row && row.id) {
  128. this.infoDialog.title = '编辑'
  129. this.$modal.loading()
  130. step_info({ id: row.id }).then(({ data }) => {
  131. this.infoDialog.formData = data
  132. }).finally(() => {
  133. this.$modal.closeLoading()
  134. })
  135. }
  136. this.infoDialog.visible = true
  137. },
  138. save() {
  139. this.$refs['infoDialogForm'].validate(valid => {
  140. if (valid) {
  141. this.$modal.loading()
  142. step_save(this.infoDialog.formData).then(() => {
  143. this.infoDialog.visible = false
  144. this.getList()
  145. }).finally(() => {
  146. this.$modal.closeLoading()
  147. })
  148. }
  149. })
  150. },
  151. del(row) {
  152. this.$confirm('确定要删除吗', '提示', {
  153. confirmButtonText: '确定',
  154. cancelButtonText: '取消',
  155. type: 'warning'
  156. })
  157. .then(() => {
  158. this.$modal.loading()
  159. step_delete({ id: row.id }).then(() => {
  160. this.getList()
  161. })
  162. .finally(() => {
  163. this.$modal.closeLoading()
  164. })
  165. })
  166. .catch(() => { })
  167. },
  168. }
  169. };
  170. </script>
  171. <style lang="scss"></style>