华西海圻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.

223 lines
6.9 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="name">
  5. <el-input v-model="searchForm.name" :placeholder="$t('form.placeholderInput')" clearable style="width: 150px"
  6. @keyup.enter.native="search" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" icon="el-icon-search" @click="search">{{ $t('form.search') }}</el-button>
  10. <el-button icon="el-icon-refresh" @click="reset">{{ $t('form.reset') }}</el-button>
  11. <el-button type="primary" plain icon="el-icon-plus" @click="edit(null)">新增</el-button>
  12. </el-form-item>
  13. </el-form>
  14. <el-table v-loading="loading" :data="list">
  15. <el-table-column label="id" align="center" prop="id" />
  16. <el-table-column label="名称" align="center" prop="name" />
  17. <el-table-column label="创建时间" align="center" prop="createTime" />
  18. <el-table-column :label="$t('form.operate')" fixed="right" align="center" width="200">
  19. <template slot-scope="scope">
  20. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  21. <el-button type="text" @click="del(scope.row)">删除</el-button>
  22. <el-button type="text" @click="selectStep(scope.row)">设置步骤</el-button>
  23. </template>
  24. </el-table-column>
  25. </el-table>
  26. <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
  27. @pagination="getList" />
  28. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="infoDialog.title" :visible.sync="infoDialog.visible" width="800px"
  29. append-to-body>
  30. <el-form ref="infoDialogForm" :model="infoDialog.formData" :rules="infoDialog.rules" label-width="180px">
  31. <el-row>
  32. <el-col :span="24">
  33. <el-form-item label="名称:" prop="name">
  34. <el-input v-model="infoDialog.formData.name" />
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </el-form>
  39. <div slot="footer" class="dialog-footer">
  40. <el-button type="primary" @click="save"> </el-button>
  41. <el-button @click="infoDialog.visible = false"> </el-button>
  42. </div>
  43. </el-dialog>
  44. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="stepDialog.title" :visible.sync="stepDialog.visible" width="800px"
  45. append-to-body>
  46. <el-table v-loading="stepDialog.loading" :data="stepDialog.stepList" ref="multipleTable" @selection-change="handleSelectionChange" height="400px">
  47. <el-table-column type="selection" width="55" />
  48. <el-table-column label="id" align="center" prop="id" />
  49. <el-table-column label="编号" align="center" prop="sn" />
  50. <el-table-column label="名称" align="center" prop="name" />
  51. <el-table-column label="创建时间" align="center" prop="createTime" />
  52. </el-table>
  53. <div slot="footer" class="dialog-footer">
  54. <el-button type="primary" @click="saveStep"> </el-button>
  55. <el-button @click="stepDialog.visible = false"> </el-button>
  56. </div>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script>
  61. import { step_list, stepGroup_list, stepGroup_info, stepGroup_save, stepGroup_delete } from "@/api/business/step/step";
  62. const EmptyDialogData = {
  63. id: '',
  64. name: '',
  65. }
  66. export default {
  67. name: "StepGroupPage",
  68. props: {
  69. },
  70. components: {
  71. },
  72. computed: {
  73. },
  74. filters: {
  75. },
  76. data() {
  77. return {
  78. searchForm: {
  79. pageNum: 1,
  80. pageSize: 10,
  81. name: '',
  82. },
  83. loading: true,
  84. total: 0,
  85. list: [],
  86. infoDialog: {
  87. title: '',
  88. visible: false,
  89. formData: {},
  90. rules: {
  91. name: [
  92. { required: true, message:'请输入', trigger: "blur" }
  93. ],
  94. },
  95. },
  96. stepDialog:{
  97. title: '设置步骤',
  98. visible: false,
  99. loading:false,
  100. stepList:[],
  101. data:{id:'',stepIds:''},
  102. }
  103. };
  104. },
  105. created() {
  106. this.getList();
  107. },
  108. methods: {
  109. getList() {
  110. this.loading = true;
  111. stepGroup_list(this.searchForm).then(response => {
  112. this.list = response.rows;
  113. this.total = response.total;
  114. this.loading = false;
  115. });
  116. },
  117. search() {
  118. this.searchForm.pageNum = 1;
  119. this.getList();
  120. },
  121. reset() {
  122. this.searchForm = {
  123. pageNum: 1,
  124. pageSize: 10,
  125. sn: '',
  126. name: '',
  127. }
  128. this.search()
  129. },
  130. edit(row) {
  131. this.$refs['infoDialogForm'] && this.$refs['infoDialogForm'].resetFields()
  132. this.infoDialog.title = '新增'
  133. this.infoDialog.formData = _.merge({}, EmptyDialogData)
  134. if (row && row.id) {
  135. this.infoDialog.title = '编辑'
  136. this.$modal.loading()
  137. stepGroup_info({ id: row.id }).then(({ data }) => {
  138. this.infoDialog.formData = data
  139. }).finally(() => {
  140. this.$modal.closeLoading()
  141. })
  142. }
  143. this.infoDialog.visible = true
  144. },
  145. save() {
  146. this.$refs['infoDialogForm'].validate(valid => {
  147. if (valid) {
  148. this.$modal.loading()
  149. stepGroup_save(this.infoDialog.formData).then(() => {
  150. this.infoDialog.visible = false
  151. this.getList()
  152. }).finally(() => {
  153. this.$modal.closeLoading()
  154. })
  155. }
  156. })
  157. },
  158. del(row) {
  159. this.$confirm('确定要删除吗', '提示', {
  160. confirmButtonText: '确定',
  161. cancelButtonText: '取消',
  162. type: 'warning'
  163. })
  164. .then(() => {
  165. this.$modal.loading()
  166. stepGroup_delete({ id: row.id }).then(() => {
  167. this.getList()
  168. })
  169. .finally(() => {
  170. this.$modal.closeLoading()
  171. })
  172. })
  173. .catch(() => { })
  174. },
  175. selectStep(row){
  176. this.stepDialog.visible = true
  177. this.stepDialog.data = _.clone(row)
  178. this.stepDialog.loading = true
  179. step_list({ pageNum: 1, pageSize:9999}).then(response => {
  180. this.stepDialog.stepList = response.rows
  181. setTimeout(() => {
  182. let cuurStepIdList = this.stepDialog.data.stepIds ? this.stepDialog.data.stepIds.split(',') : []
  183. this.stepDialog.stepList.forEach(item => {
  184. this.$refs.multipleTable.toggleRowSelection(item,cuurStepIdList.indexOf(item.id+'')>-1)
  185. });
  186. this.stepDialog.loading = false
  187. }, 1000);
  188. }).catch(() => {
  189. this.stepDialog.loading = false
  190. })
  191. },
  192. handleSelectionChange(val){
  193. if(!this.stepDialog.loading){
  194. this.stepDialog.data.stepIds = _.map(val, 'id').join(',')
  195. }
  196. },
  197. saveStep(){
  198. this.$modal.loading()
  199. stepGroup_save(this.stepDialog.data).then(() => {
  200. this.stepDialog.visible = false
  201. this.getList()
  202. }).finally(() => {
  203. this.$modal.closeLoading()
  204. })
  205. },
  206. }
  207. };
  208. </script>
  209. <style lang="scss"></style>