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

124 lines
4.2 KiB

  1. <template>
  2. <div class="select-template">
  3. <el-dialog :title="$t('page.system.template.selectTemplate')" :visible.sync="open" width="1200px" append-to-body
  4. :close-on-click-modal="false" style="padding: 20px 20px;">
  5. <div class="dialog-container">
  6. <el-form :model="searchForm" ref="searchForm" :inline="true">
  7. <el-form-item :label="$t('page.system.template.name') + ':'" prop="name">
  8. <el-input v-model="searchForm.name" :placeholder="$t('form.placeholderInput')" clearable
  9. style="width: 150px" @keyup.enter.native="search" />
  10. </el-form-item>
  11. <el-form-item :label="$t('page.system.template.department') + ':'" prop="deptId">
  12. <select-dept style="width:200px" v-model="searchForm.deptId" @change="search" />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="el-icon-search" @click="search">{{ $t('form.search') }}</el-button>
  16. <el-button icon="el-icon-refresh" @click="reset">{{ $t('form.reset') }}</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <el-table v-loading="loading" border :data="list">
  20. <!-- 单选列 -->
  21. <el-table-column width="80" align="center">
  22. <template slot-scope="scope">
  23. <el-radio v-model="selectedId" :label="scope.row.id" class="hide-label"
  24. @click.native.stop="handleRadioClick(scope.row)"></el-radio>
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="测试用" align="center" prop="sn" width="100px"/>
  28. <el-table-column :label="$t('page.system.template.sn')" align="center" prop="showSn" />
  29. <el-table-column :label="$t('page.system.template.name')" align="center">
  30. <template slot-scope="scope">
  31. <span v-if="$i18n.locale === 'zh_CN'">{{ scope.row.name }}</span>
  32. <span v-else>{{ scope.row.nameEn }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column :label="$t('page.system.template.department')" align="center" prop="deptName"
  36. width="150px" />
  37. </el-table>
  38. <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
  39. @pagination="getList" />
  40. </div>
  41. <div slot="footer" class="dialog-footer">
  42. <el-button @click="open = false">{{ $t('form.cancel') }}</el-button>
  43. <el-button type="primary" :disabled="!(this.selectedId && this.selectedId !== '')" @click="handleSelect">{{
  44. $t('form.saveConfirm') }}</el-button>
  45. </div>
  46. </el-dialog>
  47. </div>
  48. </template>
  49. <script>
  50. import { public_templateList } from "@/api/business/public/public";
  51. import SelectDept from "@/views/business/comps/select/SelectDept";
  52. export default {
  53. name: "SelectTemplateDialog",
  54. components: { SelectDept },
  55. props: {
  56. },
  57. watch: {
  58. },
  59. data() {
  60. return {
  61. selectedId: null,
  62. loading: false,
  63. open: false,
  64. total: 0,
  65. list: [],
  66. searchForm: {
  67. pageNum: 1,
  68. pageSize: 10,
  69. sn: '',
  70. name: '',
  71. deptId: null,
  72. status: '',
  73. }
  74. };
  75. },
  76. mounted() {
  77. },
  78. methods: {
  79. handleRadioClick(row) {
  80. this.selectedId = row.id
  81. },
  82. show(val) {
  83. this.searchForm.deptId=val.selectedDeptId
  84. this.searchForm = _.merge({}, this.searchForm, val)
  85. this.selectedId = null
  86. this.search()
  87. },
  88. search() {
  89. this.searchForm.pageNum = 1;
  90. this.open = true
  91. this.selectedId = null
  92. this.getList();
  93. },
  94. reset() {
  95. this.searchForm = {
  96. pageNum: 1,
  97. pageSize: 10,
  98. sn: '',
  99. name: '',
  100. deptId: null,
  101. status: '',
  102. }
  103. this.search()
  104. },
  105. getList() {
  106. public_templateList(this.searchForm).then(response => {
  107. this.list = response.rows;
  108. this.total = response.total;
  109. this.loading = false
  110. })
  111. },
  112. handleSelect() {
  113. let that = this
  114. let _index = _.findIndex(this.list, function (item) { return item.id == that.selectedId })
  115. this.$emit('callback', this.list[_index]);
  116. this.open = false
  117. }
  118. }
  119. };
  120. </script>
  121. <style rel="stylesheet/scss" lang="scss">
  122. .select-template {}
  123. </style>