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

214 lines
6.8 KiB

  1. <template>
  2. <div class="app-container template-page">
  3. <el-form :model="searchForm" ref="searchForm" :inline="true">
  4. <el-form-item :label="$t('page.system.template.sn')+':'" prop="sn">
  5. <el-input v-model="searchForm.sn" :placeholder="$t('form.placeholderInput')" clearable style="width: 150px" @keyup.enter.native="search" />
  6. </el-form-item>
  7. <el-form-item :label="$t('page.system.template.name')+':'" prop="name">
  8. <el-input v-model="searchForm.name" :placeholder="$t('form.placeholderInput')" clearable style="width: 150px" @keyup.enter.native="search" />
  9. </el-form-item>
  10. <el-form-item :label="$t('page.system.template.department')+':'" prop="deptId">
  11. <select-dept style="width:200px" v-model="searchForm.deptId" @change="search" />
  12. </el-form-item>
  13. <el-form-item :label="$t('page.system.template.status')+':'" prop="status">
  14. <el-select
  15. v-model="searchForm.status"
  16. :placeholder="$t('form.placeholderSelect')"
  17. clearable
  18. style="width: 100px"
  19. @change="search"
  20. >
  21. <el-option key="0" :label="$t('page.system.template.statusEnable')" :value="10" />
  22. <el-option key="1" :label="$t('page.system.template.statusDisable')" :value="1" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" @click="search">{{ $t('form.search') }}</el-button>
  27. <el-button icon="el-icon-refresh" @click="reset">{{ $t('form.reset') }}</el-button>
  28. <el-button type="primary" plain icon="el-icon-plus" @click="edit(null)" v-hasPermi="['system:user:add']">新增-后期不需要</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-table v-loading="loading" :data="list">
  32. <el-table-column :label="$t('page.system.template.sn')" align="center" prop="sn" />
  33. <el-table-column :label="$t('page.system.template.name')" align="center" prop="name" />
  34. <el-table-column :label="$t('page.system.template.department')" align="center" prop="deptName" />
  35. <el-table-column :label="$t('page.system.template.status')" prop="status" width="150">
  36. <template slot-scope="scope">
  37. <span v-if="scope.row.status===10">{{$t('page.system.template.statusEnable')}}</span>
  38. <span v-if="scope.row.status===1">{{$t('page.system.template.statusDisable')}}</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column :label="$t('form.operate')" fixed="right" align="center" width="100">
  42. <template slot-scope="scope">
  43. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  44. <el-button type="text" @click="edit(scope.row)">{{$t('page.system.template.detail')}}</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <pagination
  49. v-show="total>0"
  50. :total="total"
  51. :page.sync="searchForm.pageNum"
  52. :limit.sync="searchForm.pageSize"
  53. @pagination="getList"
  54. />
  55. <el-dialog :close-on-click-modal="false" :title="infoDialog.title" :visible.sync="infoDialog.visible" width="600px" append-to-body>
  56. <el-form ref="infoDialogForm" :model="infoDialog.formData" :rules="infoDialog.rules" label-width="100px">
  57. <el-row>
  58. <el-col :span="24">
  59. <el-form-item label="编号:" prop="sn">
  60. <el-input v-model="infoDialog.formData.sn" />
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="24">
  64. <el-form-item label="名称:" prop="name">
  65. <el-input v-model="infoDialog.formData.name" />
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="24">
  69. <el-form-item label="部门/学科:" prop="name">
  70. <select-dept v-model="infoDialog.formData.deptId" />
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="primary" @click="save"> </el-button>
  77. <el-button @click="infoDialog.visible = false"> </el-button>
  78. </div>
  79. </el-dialog>
  80. </div>
  81. </template>
  82. <script>
  83. import { template_list,template_info,template_save,template_delete} from "@/api/business/template/template";
  84. import SelectDept from '../comps/select/SelectDept.vue';
  85. const EmptyDialogData = {
  86. id:'',
  87. name:'',
  88. sn:'',
  89. deptId:''
  90. }
  91. export default {
  92. name: "Template",
  93. props:{
  94. },
  95. components:{
  96. SelectDept
  97. },
  98. computed: {
  99. },
  100. filters:{
  101. },
  102. data() {
  103. return {
  104. searchForm: {
  105. pageNum: 1,
  106. pageSize: 10,
  107. sn:'',
  108. name:'',
  109. deptId:null,
  110. status:'',
  111. },
  112. loading: true,
  113. total: 0,
  114. list: [],
  115. infoDialog:{
  116. title:'',
  117. visible:false,
  118. formData:{},
  119. },
  120. };
  121. },
  122. created() {
  123. this.getList();
  124. },
  125. methods: {
  126. getList() {
  127. this.loading = true;
  128. template_list(this.searchForm).then(response => {
  129. this.list = response.rows;
  130. this.total = response.total;
  131. this.loading = false;
  132. });
  133. },
  134. search() {
  135. this.searchForm.pageNum = 1;
  136. this.getList();
  137. },
  138. reset(){
  139. this.searchForm = {
  140. pageNum: 1,
  141. pageSize: 10,
  142. sn:'',
  143. name:'',
  144. deptId:null,
  145. status:'',
  146. }
  147. this.search()
  148. },
  149. edit(row) {
  150. this.$refs['infoDialogForm'] && this.$refs['infoDialogForm'].resetFields()
  151. this.infoDialog.title = '新增'
  152. this.infoDialog.formData = _.merge({}, EmptyDialogData)
  153. if(row && row.id){
  154. this.infoDialog.title = '编辑'
  155. this.$modal.loading()
  156. template_info({id:row.id}).then(({data}) => {
  157. this.infoDialog.formData = data
  158. }).finally(() => {
  159. this.$modal.closeLoading()
  160. })
  161. }
  162. this.infoDialog.visible = true
  163. // this.infoDialog.title = this.$t('page.system.template.edit')
  164. // this.$modal.loading()
  165. // template_info({id:row.id}).then(({data}) => {
  166. // this.infoDialog.formData = data
  167. // }).finally(() => {
  168. // this.$modal.closeLoading()
  169. // })
  170. },
  171. save() {
  172. this.$refs['infoDialogForm'].validate(valid => {
  173. if (valid) {
  174. this.$modal.loading()
  175. template_save(this.infoDialog.formData).then(() => {
  176. this.infoDialog.visible = false
  177. this.getList()
  178. }).finally(() => {
  179. this.$modal.closeLoading()
  180. })
  181. }
  182. })
  183. },
  184. del(row) {
  185. this.$confirm('确定要删除吗', '提示', {
  186. confirmButtonText: '确定',
  187. cancelButtonText: '取消',
  188. type: 'warning'
  189. })
  190. .then(() => {
  191. this.$modal.loading()
  192. template_delete({ id: row.id}).then(() => {
  193. this.getList()
  194. })
  195. .finally(() => {
  196. this.$modal.closeLoading()
  197. })
  198. })
  199. .catch(() => {})
  200. },
  201. }
  202. };
  203. </script>
  204. <style lang="scss">
  205. </style>