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

210 lines
7.6 KiB

2 years ago
2 years ago
  1. <template>
  2. <div class="category-main">
  3. <div class="des-preview-left">
  4. <div class="des-title">
  5. <p>字段调整 输入字段</p>
  6. </div>
  7. <ul class="des-fields">
  8. <li v-for="(item,index) in allFieldsData" v-show="item.isInput" :key="index" :class="[ fieldsActive == index ?'fields-active':'']" @click="selectField(index)">
  9. <el-tooltip class="item" effect="dark" :content="item.fieldCnName" :enterable="false" placement="top">
  10. <p>{{ item.fieldCnName }}</p>
  11. </el-tooltip>
  12. </li>
  13. </ul>
  14. <div class="des-title">
  15. <p @click="isCollaspeHiddenFields = !isCollaspeHiddenFields">非输入字段 <i :class="['el-icon-arrow-down', isCollaspeHiddenFields ?'el-icon-arrow-down':'arrow-up']" /></p>
  16. </div>
  17. <!-- 收起展开 -->
  18. <el-collapse-transition>
  19. <ul v-show="!isCollaspeHiddenFields" class="des-fields">
  20. <li v-for="(item,index) in allFieldsData" v-show="!item.isInput" :key="index" :class="[ fieldsActive == index ?'fields-active':'']" @click="selectField(index)">
  21. <el-tooltip class="item" effect="dark" :content="item.fieldCnName" :enterable="false" placement="top">
  22. <p>{{ item.fieldCnName }}</p>
  23. </el-tooltip>
  24. </li>
  25. </ul>
  26. </el-collapse-transition>
  27. <div class="des-set-btn">
  28. <el-button type="primary" icon="iconfont icon-bianji" @click="settingForm">编辑</el-button>
  29. <el-button class="des-set-sort" type="primary" icon="iconfont icon-paixu" @click="previewFormVisible = true">排序</el-button>
  30. </div>
  31. <SettingForm :is-disabled="true" :is-add="false" :this-fields="thisFields" />
  32. </div>
  33. <div class="des-preview-right">
  34. <div class="des-title">
  35. <p>界面预览效果</p>
  36. </div>
  37. <PreviewForm ref="previewForm1" :is-has-code="true" :is-disabled="false" :form-preview-data.sync="isInputFields" :selected-category="selectedCategory" :is-des-form-type="isDesFormType" />
  38. </div>
  39. <!-- 修改字段 -->
  40. <el-dialog class="edit-form-dialog" :visible="settingFormVisible" :modal-append-to-body="false" :before-close="handleClose" :close-on-click-modal="false" title="修改字段">
  41. <div class="setting-dialog">
  42. <SettingForm ref="editForm" :is-disabled="false" :is-add="false" :this-fields="editField" />
  43. <div slot="footer" class="dialog-footer">
  44. <el-button type="primary" :loading="loading" @click="editSubmit">保存</el-button>
  45. </div>
  46. </div>
  47. </el-dialog>
  48. <!-- 界面字段预览排序 -->
  49. <el-dialog class="preview-dialog sort-dialog" :visible="previewFormVisible" :modal-append-to-body="false" :before-close="handleClose" :close-on-click-modal="false" :destroy-on-close="true" title="著录界面排序">
  50. <div class="setting-dialog">
  51. <i class="drag-tip">提示使用鼠标拖动调整顺序</i>
  52. <!-- <PreviewForm :is-disabled="true" :all-fields-data="allFieldsData" .sync/> -->
  53. <PreviewForm ref="previewForm" :is-has-code="true" :is-disabled="false" :is-draggable="true" :form-preview-data="JSON.parse(JSON.stringify(isInputFields))" :is-des-form-type="isDesFormType" :selected-category="selectedCategory" />
  54. <div slot="footer" class="dialog-footer">
  55. <el-button type="primary" @click.native="handleSort">保存</el-button>
  56. </div>
  57. </div>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script>
  62. import PreviewForm from '@/views/components/category/PreviewForm'
  63. import SettingForm from '@/views/components/category/SettingForm'
  64. import { FetchArchivesTypeManage } from '@/api/category/category'
  65. import { edit } from '@/api/category/fieldManage'
  66. import { previewFormOrder } from '@/api/category/listBrowsing'
  67. export default {
  68. name: 'DescriptionPreview',
  69. components: { PreviewForm, SettingForm },
  70. props: {
  71. selectedCategory: {
  72. type: Object,
  73. default: function() {
  74. return {}
  75. }
  76. }
  77. },
  78. data() {
  79. return {
  80. allFieldsData: [],
  81. isCollaspeHiddenFields: true, // 隐藏字段收起展开
  82. settingFormVisible: false, // 修改编辑字段 - dialog
  83. previewFormVisible: false, // 界面预览form - dialog
  84. fieldsActive: 0, // 当前字段index
  85. thisFields: { dictionaryConfigId: { dicName: null, id: null }}, // 当前项字段内容
  86. editField: {},
  87. isInputFields: [],
  88. loading: false,
  89. isDesFormType: 'category'
  90. }
  91. },
  92. watch: {
  93. selectedCategory: function(newValue, oldValue) {
  94. this.getArchivesType()
  95. }
  96. },
  97. mounted() {
  98. this.getArchivesType()
  99. },
  100. methods: {
  101. getArchivesType(setField) {
  102. // 门类切换时,表单校验清除
  103. this.$refs.previewForm1.$refs['addOrUpdateForm'].clearValidate()
  104. FetchArchivesTypeManage({ categoryId: this.selectedCategory.id, isType: 2 }).then(res => {
  105. this.allFieldsData.splice(0, this.allFieldsData.length)
  106. this.isInputFields.splice(0, this.isInputFields.length)
  107. if (!setField) {
  108. setField = false
  109. }
  110. res.sort(this.compare).forEach((item, index) => {
  111. // 防止对应字典是null时报错
  112. item.dictionaryConfigId = item.dictionaryConfigId || { dicName: null, id: null }
  113. this.allFieldsData.push(item)
  114. if (item.isInput && !setField) {
  115. this.fieldsActive = index
  116. this.thisFields = item
  117. setField = true
  118. }
  119. if (item.isInput) {
  120. this.isInputFields.push(item)
  121. }
  122. })
  123. })
  124. },
  125. handleClose(done) {
  126. this.settingFormVisible = false
  127. this.previewFormVisible = false
  128. // this.editResetForm()
  129. done()
  130. },
  131. compare(a, b) {
  132. return a.isSequence - b.isSequence
  133. },
  134. settingForm() {
  135. this.editField = JSON.parse(JSON.stringify(this.thisFields))
  136. this.settingFormVisible = true
  137. },
  138. // 当前选中的字段
  139. selectField(index) {
  140. this.hiddenFieldsActive = -1
  141. this.fieldsActive = index
  142. this.thisFields = this.allFieldsData[this.fieldsActive]
  143. },
  144. // 修改字段"保存"提交
  145. editSubmit() {
  146. this.$refs['editForm'].$refs['form'].validate(valid => {
  147. if (!valid) {
  148. return
  149. }
  150. this.loading = true
  151. edit(this.editField).then(() => {
  152. this.loading = false
  153. this.$message({
  154. message: '保存成功',
  155. type: 'success',
  156. duration: 2500
  157. })
  158. this.settingFormVisible = false
  159. // 清空数组数据
  160. this.allFieldsData.splice(0, this.allFieldsData.length)
  161. this.getArchivesType(true)
  162. this.thisFields = this.editField
  163. })
  164. })
  165. return false
  166. },
  167. handleSort() {
  168. const sortParam = this.$refs.previewForm.formPreviewData.map((item, index) => {
  169. return {
  170. isSequence: index + 1,
  171. id: item.id
  172. }
  173. })
  174. previewFormOrder(sortParam).then(() => {
  175. this.previewFormVisible = false
  176. this.getArchivesType()
  177. })
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. [data-theme=dark] .category-main{
  184. .des-preview-right{
  185. border-left: 1px solid #3a99fd;
  186. }
  187. }
  188. [data-theme=light] .category-main{
  189. .des-preview-right{
  190. border-left: 1px solid #EDEFF3;
  191. }
  192. }
  193. .category-main {
  194. .des-preview-left,
  195. .des-preview-right {
  196. height: calc(100vh - 254px);
  197. }
  198. .des-preview-right{
  199. width: 1028px;
  200. padding: 0 30px;
  201. .right-preview{
  202. width: 833px;
  203. }
  204. }
  205. }
  206. </style>