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

332 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="rrr">
  3. <!--工具栏-->
  4. <div class="head-container">
  5. <div class="head-archives-top">
  6. <div class="head-search">
  7. <!-- 搜索 -->
  8. <el-input v-model="query.blurry" clearable size="small" placeholder="请输入关键词" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  9. <el-select v-model="query.enabled" clearable size="small" placeholder="状态" class="filter-item" style="width: 100px" @change="crud.toQuery">
  10. <i slot="prefix" class="iconfont icon-zhuangtai-fanbai" />
  11. <el-option v-for="item in stateOptions" :key="item.key" :label="item.label" :value="item.key" />
  12. </el-select>
  13. <rrOperation />
  14. </div>
  15. <el-checkbox v-model="fixedStatusBar">隐藏固定状态栏</el-checkbox>
  16. </div>
  17. <crudOperation :permission="permission">
  18. <template v-slot:right>
  19. <el-button v-permission="permission.del" icon="el-icon-delete" size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)">删除</el-button>
  20. <el-button v-permission="permission.download" :loading="crud.downloadLoading" :disabled="!crud.data.length" size="mini" icon="el-icon-download" @click="crud.doExport">导出</el-button>
  21. </template>
  22. <template v-slot:rightButtonGroup>
  23. <div class="archives-handler-btn">
  24. <el-button class="packing-btn iconfont icon-weibiaoti-2" type="primary">装盒</el-button>
  25. <el-button class="warehousing-btn iconfont icon-weibiaoti-2" type="primary">入库</el-button>
  26. <el-button class="lending-btn iconfont icon-weibiaoti-2" type="primary">借阅</el-button>
  27. <el-button class="binding-btn iconfont icon-weibiaoti-2" type="primary">绑定标签</el-button>
  28. </div>
  29. </template>
  30. </crudOperation>
  31. </div>
  32. <!--新增 / 编辑 表单组件-->
  33. <el-dialog class="preview-dialog" :modal-append-to-body="false" :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title">
  34. <span class="dialog-right-top" />
  35. <span class="dialog-left-bottom" />
  36. <div class="setting-dialog">
  37. <ul class="archives-tab">
  38. <li :class="{'active': archivesTabIndex == 0}" @click="changeActiveTab(0)">基本信息</li>
  39. <li v-if="isEditOrAdd !== 'add'" :class="{'active': archivesTabIndex == 1}" @click="changeActiveTab(1)">上传附件</li>
  40. </ul>
  41. <PreviewForm v-if="formPreviewData.length && archivesTabIndex == 0" ref="previewForm" :is-disabled="false" :form-preview-data.sync="formPreviewData" :selected-category="selectedCategory" :arc-id="arcId" />
  42. <UploadFile v-if="archivesTabIndex==1" />
  43. <div slot="footer" class="dialog-footer">
  44. <el-button :loading="crud.status.cu === 2" type="primary" @click="handlerArchivesSubmit">保存</el-button>
  45. </div>
  46. </div>
  47. </el-dialog>
  48. <!-- 删除档案 -->
  49. <el-dialog title="删除档案" :visible.sync="deleteVisible" :before-close="handleClose">
  50. <span class="dialog-right-top" />
  51. <span class="dialog-left-bottom" />
  52. <div class="setting-dialog">
  53. <div class="dialog-delt">
  54. <p><span>确定删除当前档案吗</span></p>
  55. <p v-if="selectedCategory.isType == 2">数据来源项目 1条数据 案卷 4条数据</p>
  56. <p v-if="selectedCategory.isType == 3">数据来源案卷 1条数据 卷内 2条数据</p>
  57. <p v-if="selectedCategory.isType == 4">数据来源卷内 1条数据</p>
  58. <p v-if="selectedCategory.isType == 5">数据来源卷内 1条数据</p>
  59. <p class="delt-tip"><span>提示如果删除当前档案此档案内所附带的文件会一并删除</span></p>
  60. </div>
  61. <div slot="footer" class="dialog-footer">
  62. <el-button type="primary" @click.native="handleDeltConfirm">确定</el-button>
  63. </div>
  64. </div>
  65. </el-dialog>
  66. <!-- table表格渲染 -->
  67. <el-table ref="table" v-loading="crud.loading || getTableDisplayFieldsLoading" class="archives-table" :data="crud.data" highlight-current-row style="width: 100%; " height="calc(100vh - 370px)" @selection-change="crud.selectionChangeHandler" @row-click="clickRowHandler">
  68. <el-table-column type="selection" width="55" align="center" />
  69. <el-table-column type="index" label="序号" width="55" align="center" />
  70. <el-table-column v-for="field in tableDisplayFields" :key="field.id" :label="field.fieldCnName" :align="field.displayformatType" :width="field.displayLength" show-overflow-tooltip>
  71. <template slot-scope="scope">
  72. {{ scope.row[field.fieldName] }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="装盒" width="100" align="center" :fixed="fixedStatusBar?false:'right'">
  76. <!-- state-active 已装/已入/已借/已绑 -->
  77. <template slot-scope="scope">
  78. <!-- 未装 / 已装 -->
  79. <span class="row-state row-packing state-active">{{ scope.row.case_no ? '已装': '未装' }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="入库" width="100" align="center" :fixed="fixedStatusBar?false:'right'">
  83. <template slot-scope="">
  84. <!-- 未入 / 已入 -->
  85. <span class="row-state row-warehousing">未入</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="借阅" width="100" align="center" :fixed="fixedStatusBar?false:'right'">
  89. <template slot-scope="">
  90. <!-- 待借 / 不可借- 表示 / 已借 -->
  91. <span class="row-state row-lending"></span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="标签" width="100" align="center" :fixed="fixedStatusBar?false:'right'">
  95. <template slot-scope="scope">
  96. <!-- 未绑 / 已绑 -->
  97. <span class="row-state row-binding">{{ scope.row.tid ? '已绑': '未绑' }}</span>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <!--分页组件-->
  102. <pagination />
  103. </div>
  104. </template>
  105. <script>
  106. import { add, edit, del, getTableDisplayFields, getFormDisplayFields } from '@/api/archivesManage/archivesList'
  107. import CRUD, { presenter, header, form } from '@crud/crud'
  108. import crudOperation from '@crud/CRUD.operation'
  109. import rrOperation from '@crud/RR.operation'
  110. import pagination from '@crud/Pagination'
  111. import PreviewForm from '@/views/components/category/PreviewForm'
  112. import UploadFile from './module/uploadFile'
  113. export default {
  114. components: { crudOperation, rrOperation, pagination, PreviewForm, UploadFile },
  115. mixins: [
  116. presenter(),
  117. header(),
  118. form({})
  119. ],
  120. props: {
  121. selectedCategory: {
  122. type: Object,
  123. default: function() {
  124. return {}
  125. }
  126. }
  127. },
  128. cruds() {
  129. return [
  130. CRUD({
  131. title: '档案',
  132. url: 'api/archives/initArchivesView',
  133. query: { isdel: false },
  134. crudMethod: { add, edit, del },
  135. optShow: {
  136. add: true,
  137. edit: true,
  138. del: false,
  139. reset: false,
  140. download: false,
  141. group: false
  142. },
  143. queryOnPresenterCreated: false,
  144. sort: ['department,asc']
  145. })
  146. ]
  147. },
  148. data() {
  149. return {
  150. stateOptions: [ // 搜索 - 状态选择
  151. { key: '1', label: '全部' },
  152. { key: '2', label: '未装' },
  153. { key: '3', label: '未入' },
  154. { key: '4', label: '在库' },
  155. { key: '5', label: '待借' },
  156. { key: '6', label: '已借' }
  157. ],
  158. permission: {
  159. add: ['admin', 'archivesList:add'],
  160. edit: ['admin', 'archivesList:edit'],
  161. del: ['admin', 'archivesList:del'],
  162. download: ['admin', 'archivesList:download']
  163. },
  164. fixedStatusBar: false, // table-右侧fixed
  165. deleteVisible: false, // 删除dialog
  166. deleteData: {}, // 删除选中data
  167. tableDisplayFields: [], // table-list-title字段
  168. getTableDisplayFieldsLoading: false, // table-loading
  169. formPreviewData: [], // 预览界面data
  170. isEditOrAdd: '',
  171. selectedData: null,
  172. archivesTabIndex: 0, // 新增
  173. tabDisabled: true,
  174. arcId: null // 档案ID
  175. }
  176. },
  177. watch: {
  178. selectedCategory: function(newValue, oldValue) {
  179. // 案卷 卷内 文件
  180. if (newValue.isType === 3 || newValue.isType === 4 || newValue.isType === 5) {
  181. this.crud.query.categoryId = newValue.id
  182. this.crud.refresh()
  183. }
  184. },
  185. tableDisplayFields(val) {
  186. this.doLayout()
  187. }
  188. },
  189. mounted() {
  190. },
  191. methods: {
  192. // 获取数据前设置默认参数
  193. // [CRUD.HOOK.beforeRefresh]() {
  194. // this.crud.query.id = this.dicPid
  195. // },
  196. // [CRUD.HOOK.afterRefresh](crud) {
  197. // console.log(this.curd)
  198. // // if (this.needRefreshTree) {
  199. // // this.$emit('treeRefresh', crud.data)
  200. // // }
  201. // },
  202. [CRUD.HOOK.beforeRefresh]() {
  203. this.getTableDisplayFieldsLoading = true
  204. // 档案列表获取显示列
  205. getTableDisplayFields({ categoryId: this.selectedCategory.id }).then(data => {
  206. this.tableDisplayFields = data
  207. this.getTableDisplayFieldsLoading = false
  208. return true
  209. })
  210. },
  211. [CRUD.HOOK.beforeToCU](crud, form, btn) {
  212. this.isEditOrAdd = btn
  213. this.selectedData = crud.selections
  214. if (this.isEditOrAdd === 'add') {
  215. this.tabDisabled = true
  216. this.arcId = null
  217. } else if (this.isEditOrAdd === 'edit') {
  218. this.arcId = this.selectedData[0].id
  219. this.tabDisabled = false
  220. }
  221. this.form.dictionaryConfigId = {}
  222. this.formPreviewData = []
  223. // 档案预编辑获取字段
  224. getFormDisplayFields({ categoryId: this.selectedCategory.id }).then(data => {
  225. // this.formPreviewData = data.showFiled.filter((fields) => { return fields.isInput })
  226. this.formPreviewData = data.showFiled
  227. this.form.categoryId = this.selectedCategory.id
  228. this.$nextTick(() => {
  229. if (this.isEditOrAdd === 'edit') {
  230. this.$refs.previewForm.addOrUpdateForm = this.selectedData[0]
  231. }
  232. })
  233. return true
  234. })
  235. },
  236. // [CRUD.HOOK.beforeToEdit](crud, form, btn) {
  237. // console.log(this.crud)
  238. // this.$nextTick(() => {
  239. // console.log(this.$refs.previewForm)
  240. // })
  241. // },
  242. changeActiveTab(index) {
  243. this.archivesTabIndex = index
  244. },
  245. handlerArchivesSubmit() {
  246. // let arcId
  247. // if (this.isEditOrAdd === 'add') {
  248. // arcId = null
  249. // this.tabDisabled = true
  250. // } else if (this.isEditOrAdd === 'edit') {
  251. // arcId = this.selectedData[0].id
  252. // this.tabDisabled = false
  253. // }
  254. this.$refs.previewForm.submitForm('addOrUpdateForm')
  255. },
  256. // table - 当前选中得row
  257. clickRowHandler(row) {
  258. this.$refs.table.toggleRowSelection(row)
  259. },
  260. // 选择删除
  261. toDelete(data) {
  262. this.deleteData = data
  263. this.deleteVisible = true
  264. },
  265. // 确认删除
  266. handleDeltConfirm() {
  267. this.deleteVisible = false
  268. this.crud.delAllLoading = true
  269. // this.crud.doDelete(this.deleteData)
  270. const ids = []
  271. this.deleteData.forEach(val => {
  272. ids.push(val.id)
  273. })
  274. const params = {
  275. 'ids': ids,
  276. 'categoryId': this.selectedCategory.id
  277. }
  278. // 删除fetch
  279. del(params).then(res => {
  280. this.crud.delAllLoading = false
  281. this.$notify({
  282. title: '删除成功',
  283. type: 'success',
  284. duration: 2500
  285. })
  286. this.crud.refresh()
  287. })
  288. },
  289. // 删除 - 关闭
  290. handleClose(done) {
  291. this.deleteData = {}
  292. done()
  293. },
  294. /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */
  295. doLayout() {
  296. this.$nextTick(() => {
  297. this.$refs.table.doLayout()
  298. })
  299. }
  300. }
  301. }
  302. </script>
  303. <style rel="stylesheet/scss" lang="scss" scoped>
  304. @import "~@/assets/styles/archives-manage.scss";
  305. .preview-dialog {
  306. ::v-deep .el-dialog {
  307. width: 940px !important;
  308. .el-dialog__body{
  309. padding: 0;
  310. height: calc(100vh - 174px);
  311. }
  312. .preview-content {
  313. overflow: hidden;
  314. overflow-y: auto;
  315. .el-textarea__inner {
  316. border: 1px solid #339cff;
  317. background-color: transparent;
  318. }
  319. }
  320. .el-dialog__header {
  321. width: 420px;
  322. }
  323. .dialog-footer{
  324. margin: 0 auto;
  325. padding: 15px 0 30px 0;
  326. }
  327. }
  328. }
  329. </style>