阅行客电子档案
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
7.0 KiB

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