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

223 lines
8.2 KiB

2 years ago
  1. <template>
  2. <div class="subject-contaier">
  3. <div class="head-container">
  4. <crudOperation :permission="permission" crud-tag="field">
  5. <template v-slot:right>
  6. <el-button size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)"><i class="iconfont icon-shanchu" />删除</el-button>
  7. <el-button size="mini" @click="toQuick"><i class="iconfont icon-kuaisushezhi" />快速设置</el-button>
  8. </template>
  9. </crudOperation>
  10. </div>
  11. <!--表格渲染-->
  12. <el-table ref="fieldTable" v-loading="crud.loading" :data="crud.data" style="min-width: 100%;" height="calc(100vh - 286px)" crud-tag="field" @selection-change="selectionChangeHandler" @row-click="clickRowHandler">
  13. <el-table-column type="selection" width="55" />
  14. <el-table-column type="index" label="序号" width="55" />
  15. <el-table-column prop="fieldCnName" label="字段名称" min-width="145" show-overflow-tooltip />
  16. <el-table-column prop="fieldName" label="字段标识" min-width="145" show-overflow-tooltip />
  17. <el-table-column label="数据类型" min-width="85">
  18. <template slot-scope="scope">
  19. <span v-if="scope.row.isDataType === 1">字符</span>
  20. <span v-if="scope.row.isDataType === 2">数字</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="isColumnLength" label="字段长度" min-width="85" />
  24. <el-table-column label="著录形式" min-width="85">
  25. <template slot-scope="scope">
  26. <span v-if="scope.row.isInputClass === 'select'">下拉框</span>
  27. <span v-if="scope.row.isInputClass === 'text'">文本框</span>
  28. <span v-if="scope.row.isInputClass === 'date'">日期框</span>
  29. <span v-if="scope.row.isInputClass === 'number'">数字框</span>
  30. <span v-if="scope.row.isInputClass === 'popover'">弹出框</span>
  31. <span v-if="scope.row.isInputClass === 'textarea'">文本域</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="dictionaryConfigId.dicName" label="对应字典" min-width="85" show-overflow-tooltip />
  35. <el-table-column prop="editLength" label="显示长度" min-width="85" />
  36. <el-table-column label="显示一整行" min-width="110" align="center">
  37. <template slot-scope="scope">
  38. <el-checkbox v-model="scope.row.isLine" :disabled="true" />
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="输入字段" min-width="85" align="center">
  42. <template slot-scope="scope">
  43. <el-checkbox v-model="scope.row.isInput" :disabled="true" />
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="必填字段" min-width="85" align="center">
  47. <template slot-scope="scope">
  48. <el-checkbox v-model="scope.row.isRequired" :disabled="true" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="自动生成" min-width="85" align="center">
  52. <template slot-scope="scope">
  53. <el-checkbox v-model="scope.row.isAuto" :disabled="true" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="自动补零" min-width="85" align="center">
  57. <template slot-scope="scope">
  58. <el-checkbox v-model="scope.row.isFilling" :disabled="true" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="fillingDigit" label="位数" min-width="55" align="center" :formatter="digitFormatter" />
  62. <el-table-column label="值不重复" min-width="85" align="center">
  63. <template slot-scope="scope">
  64. <el-checkbox v-model="scope.row.isRepeat" :disabled="true" />
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <!--表单渲染-->
  69. <eForm crud-tag="field" />
  70. <quickSetting ref="quick" />
  71. <el-dialog title="删除字段" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="deleteVisible" :before-close="handleClose">
  72. <span class="dialog-right-top" />
  73. <span class="dialog-left-bottom" />
  74. <div class="setting-dialog">
  75. <div class="dialog-delt">
  76. <p><span>确定要删除当前字段吗</span></p>
  77. </div>
  78. <div slot="footer" class="dialog-footer">
  79. <el-button type="primary" @click.native="handleConfirm">确定</el-button>
  80. </div>
  81. </div>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import fieldCrudMethod from '@/api/category/fieldManage'
  87. import eForm from './module/form'
  88. import quickSetting from './module/quickSetting'
  89. import CRUD, { presenter } from '@crud/crud'
  90. import crudOperation from '@crud/CRUD.operation'
  91. export default {
  92. components: { eForm, quickSetting, crudOperation },
  93. mixins: [
  94. presenter()
  95. ],
  96. cruds() {
  97. return CRUD({
  98. tag: 'field',
  99. url: 'api/arc-dic/manage',
  100. crudMethod: fieldCrudMethod,
  101. title: '字段',
  102. optShow: {
  103. add: true,
  104. edit: true,
  105. del: false,
  106. download: false,
  107. group: false
  108. }
  109. })
  110. },
  111. props: {
  112. selectedCategory: {
  113. type: Object,
  114. default: function() {
  115. return {}
  116. }
  117. }
  118. },
  119. data() {
  120. return {
  121. permission: {
  122. add: ['admin', 'fieldManage:add'],
  123. edit: ['admin', 'fieldManage:edit'],
  124. del: ['admin', 'fieldManage:edit']
  125. },
  126. deleteVisible: false,
  127. deleteData: {},
  128. delLoading: false
  129. }
  130. },
  131. watch: {
  132. selectedCategory: function(newValue, oldValue) {
  133. this.crud.refresh()
  134. }
  135. },
  136. methods: {
  137. // 获取数据前设置默认参数
  138. [CRUD.HOOK.beforeRefresh]() {
  139. this.crud.query.categoryId = this.selectedCategory.id
  140. this.crud.query.isType = 2
  141. },
  142. [CRUD.HOOK.afterRefresh](crud) {
  143. crud.data.forEach(function(item, index) {
  144. item.dictionaryConfigId = item.dictionaryConfigId || { id: null }
  145. })
  146. },
  147. [CRUD.HOOK.beforeValidateCU](crud) {
  148. // 页面重复添加信息时,下拉框的校验会存在,需要手工取消
  149. crud.findVM('form').$refs['editForm'].$refs['form'].validate(valid => {
  150. if (!valid) {
  151. return
  152. }
  153. if (crud.status.add === CRUD.STATUS.PREPARED) {
  154. crud.doAdd()
  155. } else if (crud.status.edit === CRUD.STATUS.PREPARED) {
  156. crud.doEdit()
  157. }
  158. })
  159. return false
  160. },
  161. [CRUD.HOOK.beforeSubmit]() {
  162. if (this.crud.status.add > CRUD.STATUS.NORMAL) {
  163. this.crud.form.isSequence = this.crud.data.reduce((prev, cur) => { return { isSequence: Math.max(prev.isSequence, cur.isSequence) } }).isSequence + 1
  164. }
  165. },
  166. [CRUD.HOOK.beforeToCU]() {
  167. if (this.crud.findVM('form').$refs['editForm']) {
  168. this.crud.findVM('form').$refs['editForm'].$refs['form'].clearValidate()
  169. }
  170. },
  171. clickRowHandler(row) {
  172. this.$refs.fieldTable.clearSelection()
  173. this.$refs.fieldTable.toggleRowSelection(row)
  174. },
  175. selectionChangeHandler(val) {
  176. if (val.length > 1) {
  177. // 取出最后val的最后一个返回出来
  178. const finalVal = val.pop()
  179. // 清除所有选中
  180. this.$refs.fieldTable.clearSelection()
  181. // 给最后一个加上选中
  182. this.$refs.fieldTable.toggleRowSelection(finalVal)
  183. this.crud.selectionChangeHandler([finalVal])
  184. } else {
  185. this.crud.selectionChangeHandler(val)
  186. }
  187. },
  188. toDelete(data) {
  189. if (data[0].isSystem) {
  190. this.$message({
  191. message: '系统字段不可删除',
  192. type: 'warning',
  193. duration: 2500
  194. })
  195. return
  196. }
  197. this.deleteData = data
  198. this.deleteVisible = true
  199. },
  200. handleConfirm() {
  201. this.deleteVisible = false
  202. this.crud.delAllLoading = true
  203. this.crud.doDelete(this.deleteData)
  204. },
  205. handleClose(done) {
  206. this.deleteData = {}
  207. done()
  208. },
  209. digitFormatter(row, column, cellValue) {
  210. return cellValue || '-'
  211. },
  212. toQuick() {
  213. this.$refs.quick.quickTableData = JSON.parse(JSON.stringify(this.crud.data))
  214. this.$refs.quick.quickVisible = true
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. </style>