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

186 lines
5.7 KiB

3 years ago
3 years ago
  1. <template>
  2. <div class="app-container">
  3. <!--工具栏-->
  4. <div class="head-container" style="padding:0 0 20px 0">
  5. <crudOperation :permission="permission" />
  6. </div>
  7. <div class="container-wrap" style="min-height: calc(100vh - 241px);">
  8. <span class="right-top-line" />
  9. <span class="left-bottom-line" />
  10. <!--表格渲染-->
  11. <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" height="calc(100vh - 263px)" @selection-change="selectionChangeHandler" @row-click="clickRowHandler">
  12. <el-table-column type="selection" width="55" />
  13. <el-table-column type="index" label="序号" width="55" />
  14. <el-table-column prop="fieldCnName" label="中文名称" />
  15. <el-table-column prop="fieldName" label="字段标识" />
  16. <el-table-column label="数据类型">
  17. <template slot-scope="scope">
  18. <span v-if="scope.row.isDataType === 1">字符</span>
  19. <span v-if="scope.row.isDataType === 2">数字</span>
  20. </template>
  21. </el-table-column>
  22. <el-table-column prop="isColumnLength" label="字段长度" />
  23. <el-table-column label="默认值">
  24. <template slot-scope="scope">
  25. <span v-if="scope.row.isDefaultValue === ''">-</span>
  26. <span v-else>{{ scope.row.isDefaultValue }}</span>
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. </div>
  31. <!--表单渲染-->
  32. <eForm ref="eform" />
  33. <el-dialog title="关键提示" :visible.sync="verifyDialogVisible" :before-close="handleClose">
  34. <span class="dialog-right-top" />
  35. <span class="dialog-left-bottom" />
  36. <div class="setting-dialog">
  37. <div class="dialog-delt">
  38. <p><span>这里为技术人员维护系统时使用用户无需设置</span></p>
  39. <p class="delt-tip"><span>注意强行修改会导致系统数据异常或丢失如因用户强行修改本系统不负责因此导致的相关后果</span></p>
  40. </div>
  41. <el-form :model="form" @submit.native.prevent>
  42. <el-form-item label="技术维护验证码" :label-width="formLabelWidth">
  43. <el-input v-model="form.verifyCode" />
  44. </el-form-item>
  45. </el-form>
  46. <div slot="footer" class="dialog-footer">
  47. <el-button type="primary" @click.native="handleConfirm">确定验证</el-button>
  48. </div>
  49. </div>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script>
  54. import { add, edit, verifyMaintenance } from '@/api/archivesConfig/field'
  55. import eForm from './module/form'
  56. import { encrypt } from '@/utils/rsaEncrypt'
  57. import CRUD, { presenter } from '@crud/crud'
  58. import crudOperation from '@crud/CRUD.operation'
  59. export default {
  60. name: 'Field',
  61. components: { eForm, crudOperation },
  62. mixins: [presenter()],
  63. cruds() {
  64. return CRUD({
  65. url: 'api/field/findGroupType',
  66. crudMethod: { add, edit },
  67. optShow: {
  68. add: true,
  69. edit: true,
  70. del: false,
  71. download: false,
  72. group: false
  73. },
  74. queryOnPresenterCreated: false
  75. })
  76. },
  77. props: {
  78. isType: {
  79. type: Number,
  80. default: 1
  81. },
  82. title: {
  83. type: String,
  84. default: ''
  85. },
  86. permissionStr: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data() {
  92. return {
  93. permission: {
  94. add: ['admin', this.permissionStr + ':add'],
  95. edit: ['admin', this.permissionStr + ':edit']
  96. },
  97. verifyDialogVisible: false,
  98. form: {
  99. verifyCode: ''
  100. },
  101. formLabelWidth: '110px',
  102. btn: '',
  103. showVerifyDialog: true
  104. }
  105. },
  106. created() {
  107. this.crud.title = this.title
  108. this.crud.query = {
  109. isType: this.isType
  110. }
  111. this.crud.toQuery()
  112. },
  113. methods: {
  114. [CRUD.HOOK.beforeToCU](crud, form, btn) {
  115. if (this.showVerifyDialog) {
  116. // 打开输入验证码对话框
  117. this.verifyDialogVisible = true
  118. this.btn = btn
  119. return false
  120. }
  121. },
  122. [CRUD.HOOK.beforeToEdit](crud, form, btn) {
  123. if (form.isColumnLength === null) {
  124. form.isColumnLength = undefined
  125. }
  126. },
  127. [CRUD.HOOK.beforeSubmit]() {
  128. this.crud.form.isType = this.isType
  129. if (!this.crud.form.isSequence) {
  130. this.crud.form.isSequence = this.crud.data.reduce((prev, cur) => { return { isSequence: Math.max(prev.isSequence, cur.isSequence) } }).isSequence + 1
  131. }
  132. },
  133. handleConfirm() {
  134. verifyMaintenance(encrypt(this.form.verifyCode)).then((res) => {
  135. if (res) {
  136. // 关闭输入验证码对话框
  137. this.verifyDialogVisible = false
  138. this.form.verifyCode = ''
  139. this.showVerifyDialog = false
  140. if (this.btn === 'add') {
  141. this.crud.toAdd()
  142. } else if (this.btn === 'edit') {
  143. this.crud.toEdit(this.crud.selections[0])
  144. }
  145. this.showVerifyDialog = true
  146. } else {
  147. this.$message.error('验证码错误!')
  148. }
  149. })
  150. },
  151. handleClose(done) {
  152. this.form.verifyCode = ''
  153. done()
  154. },
  155. clickRowHandler(row) {
  156. this.$refs.table.clearSelection()
  157. this.$refs.table.toggleRowSelection(row)
  158. },
  159. selectionChangeHandler(val) {
  160. if (val.length > 1) {
  161. // 取出最后val的最后一个返回出来
  162. const finalVal = val.pop()
  163. // 清除所有选中
  164. this.$refs.table.clearSelection()
  165. // 给最后一个加上选中
  166. this.$refs.table.toggleRowSelection(finalVal)
  167. this.crud.selectionChangeHandler([finalVal])
  168. } else {
  169. this.crud.selectionChangeHandler(val)
  170. }
  171. }
  172. }
  173. }
  174. </script>
  175. <style rel="stylesheet/scss" lang="scss" scoped>
  176. ::v-deep thead .el-table-column--selection .cell {
  177. display: none;
  178. }
  179. ::v-deep div.el-dialog__footer {
  180. text-align: center;
  181. }
  182. </style>