【前端】智能库房综合管理系统前端项目
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.

164 lines
5.3 KiB

  1. <template>
  2. <div class="app-container container-wrap">
  3. <span class="right-top-line" />
  4. <span class="left-bottom-line" />
  5. <!--工具栏-->
  6. <div class="head-container">
  7. <crudOperation :permission="permission" />
  8. </div>
  9. <!--表格渲染-->
  10. <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="selectionChangeHandler" @row-click="clickRowHandler">
  11. <el-table-column type="selection" width="55" />
  12. <el-table-column type="index" label="序号" width="55" />
  13. <el-table-column prop="field_cn_name" label="中文名称" />
  14. <el-table-column prop="field_name" label="字段标识" />
  15. <el-table-column label="数据类型">
  16. <template slot-scope="scope">
  17. <span v-if="scope.row.is_data_type === 1">字符</span>
  18. <span v-if="scope.row.is_data_type === 2">数字</span>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="is_column_length" label="字段长度" />
  22. <el-table-column label="默认值">
  23. <template slot-scope="scope">
  24. <span v-if="scope.row.is_default_value === ''">-</span>
  25. <span v-else>{{ scope.row.is_default_value }}</span>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. <!--表单渲染-->
  30. <eForm />
  31. <el-dialog title="关键提示" :visible.sync="verifyDialogVisible" width="35%" :before-close="handleClose">
  32. <p><span>这里为技术人员维护系统时使用用户无需设置</span></p>
  33. <p><span style="color:red;">注意强行修改会导致系统数据异常或丢失如因用户强行修改本系统不负责因此导致的相关后果</span></p>
  34. <el-form :model="form">
  35. <el-form-item label="技术维护验证码" :label-width="formLabelWidth">
  36. <el-input v-model="form.verifyCode" />
  37. </el-form-item>
  38. </el-form>
  39. <span slot="footer" class="dialog-footer">
  40. <el-button type="primary" @click.native="handleConfirm"> </el-button>
  41. </span>
  42. </el-dialog>
  43. </div>
  44. </template>
  45. <script>
  46. import crudFields from '@/api/archivesConfig/field'
  47. import eForm from './module/form'
  48. import CRUD, { presenter } from '@crud/crud'
  49. import crudOperation from '@crud/CRUD.operation'
  50. export default {
  51. name: 'CommonFields',
  52. components: { eForm, crudOperation },
  53. cruds() {
  54. return CRUD({
  55. title: '常用字段',
  56. url: 'api/field/findGroupType',
  57. crudMethod: { ...crudFields },
  58. optShow: {
  59. add: true,
  60. edit: true,
  61. del: false,
  62. download: false,
  63. group: false
  64. },
  65. query: {
  66. is_type: 2
  67. }
  68. })
  69. },
  70. mixins: [presenter()],
  71. data() {
  72. return {
  73. permission: {
  74. add: ['admin', 'commonFields:add'],
  75. edit: ['admin', 'commonFields:edit']
  76. },
  77. verifyDialogVisible: false,
  78. form: {
  79. verifyCode: ''
  80. },
  81. formLabelWidth: '110px'
  82. }
  83. },
  84. methods: {
  85. // 获取数据前设置好接口地址
  86. // [CRUD.HOOK.beforeToCU]() {
  87. // const h = this.$createElement
  88. // return this.$prompt(h('p', null, [
  89. // h('span', null, '这里为技术人员维护系统时使用,用户级无需设置。'),
  90. // h('br', null, ''),
  91. // h('span', { style: 'color: red' }, '警告:强行修改会导致系统数据异常或丢失!如因用户强行修改,本系统不负责因此导致的相关后果!')
  92. // ]), '关键提示', {
  93. // confirmButtonText: '确定验证',
  94. // showCancelButton: false,
  95. // customClass: 'validate',
  96. // beforeClose: (action, instance, done) => {
  97. // if (action === 'confirm') {
  98. // if (instance.inputValue === '123') {
  99. // done()
  100. // } else {
  101. // this.$message.error('验证码错误!')
  102. // }
  103. // } else {
  104. // done()
  105. // }
  106. // }
  107. // }).then(({ value }) => {
  108. // // call crud.status.add = CRUD.STATUS.PREPARED
  109. // }).catch(() => {
  110. // return false
  111. // })
  112. // },
  113. // 获取数据前设置好接口地址
  114. [CRUD.HOOK.beforeToCU]() {
  115. this.verifyDialogVisible = true
  116. },
  117. handleConfirm() {
  118. if (this.form.verifyCode === '123') {
  119. this.verifyDialogVisible = false
  120. this.form.verifyCode = ''
  121. } else {
  122. this.$message.error('验证码错误!')
  123. }
  124. },
  125. handleClose(done) {
  126. this.form.verifyCode = ''
  127. done()
  128. },
  129. clickRowHandler(row) {
  130. this.$refs.table.clearSelection()
  131. this.$refs.table.toggleRowSelection(row)
  132. },
  133. selectionChangeHandler(val) {
  134. if (val.length > 1) {
  135. // 取出最后val的最后一个返回出来
  136. const finalVal = val.pop()
  137. // 清除所有选中
  138. this.$refs.table.clearSelection()
  139. // 给最后一个加上选中
  140. this.$refs.table.toggleRowSelection(finalVal)
  141. this.crud.selectionChangeHandler([finalVal])
  142. } else {
  143. this.crud.selectionChangeHandler(val)
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style rel="stylesheet/scss" lang="scss" scoped>
  150. ::v-deep thead .el-table-column--selection .cell {
  151. display: none;
  152. }
  153. .validate .el-message-box__btns {
  154. text-align: center;
  155. }
  156. </style>
  157. <style rel="stylesheet/scss" lang="scss">
  158. .validate .el-message-box__btns {
  159. text-align: center;
  160. }
  161. </style>