图书馆综合管理系统
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.

230 lines
7.9 KiB

7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
  1. <template>
  2. <div class="app-container row-container">
  3. <div class="head-container">
  4. <div class="head-search">
  5. <!-- 搜索 -->
  6. <el-input v-model="query.collectionName" clearable size="small" placeholder="输入馆藏名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  7. <rrOperation />
  8. </div>
  9. <crudOperation :permission="permission">
  10. <template v-slot:middle>
  11. <el-button slot="reference" size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)">
  12. <i class="iconfont icon-shanchu" />
  13. 删除
  14. </el-button>
  15. </template>
  16. <template v-slot:right>
  17. <el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)">
  18. <i class="iconfont icon-daochu" />
  19. 导出
  20. </el-button>
  21. </template>
  22. </crudOperation>
  23. </div>
  24. <div class="container-wrap">
  25. <span class="right-top-line" />
  26. <span class="left-bottom-line" />
  27. <!--表格渲染-->
  28. <el-table
  29. ref="table"
  30. v-loading="crud.loading"
  31. :data="crud.data"
  32. style="width: 100%;"
  33. @selection-change="crud.selectionChangeHandler"
  34. @row-click="clickRowHandler"
  35. >
  36. <el-table-column type="selection" align="center" width="55" />
  37. <el-table-column prop="collectionName" label="馆藏地名称" />
  38. <el-table-column prop="collectionFloor" label="楼层" />
  39. <el-table-column prop="collectionExplain" label="说明">
  40. <template slot-scope="scope">
  41. <div>{{ scope.row.collectionExplain ? scope.row.collectionExplain : '-' }}</div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop="createTime" label="创建时间" min-width="180">
  45. <template slot-scope="scope">
  46. <div>{{ scope.row.createTime | parseTime }}</div>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <!--分页组件-->
  51. <pagination v-if="crud.data.length!==0" />
  52. </div>
  53. <!-- form -->
  54. <el-dialog append-to-body :close-on-click-modal="false" :modal-append-to-body="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title">
  55. <span class="dialog-right-top" />
  56. <span class="dialog-left-bottom" />
  57. <div class="setting-dialog">
  58. <el-form ref="form" :rules="rules" :model="form" size="small" label-width="100px">
  59. <el-form-item label="所在楼层" prop="collectionFloor">
  60. <el-input v-model="form.collectionFloor" style="width: 580px;" />
  61. </el-form-item>
  62. <el-form-item label="馆藏地名称" prop="collectionName">
  63. <el-input v-model="form.collectionName" placeholder="请输入" style="width: 580px;" />
  64. </el-form-item>
  65. <el-form-item label="馆藏地编码" prop="collectionCode">
  66. <el-input v-model="form.collectionCode" placeholder="请输入" style="width: 580px;" />
  67. </el-form-item>
  68. <el-form-item label="说明" prop="collectionExplain">
  69. <el-input v-model="form.collectionExplain" placeholder="请输入" type="textarea" rows="3" style="width: 580px;" />
  70. </el-form-item>
  71. </el-form>
  72. <div slot="footer" class="dialog-footer">
  73. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  74. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">保存</el-button>
  75. </div>
  76. </div>
  77. </el-dialog>
  78. </div>
  79. </template>
  80. <script>
  81. import crudBookBasice from '@/api/bookBasice/index'
  82. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  83. import crudOperation from '@crud/CRUD.operation'
  84. import rrOperation from '@crud/RR.operation'
  85. import pagination from '@crud/Pagination'
  86. import { parseTime, saveAs, getBlob } from '@/utils/index'
  87. import qs from 'qs'
  88. import { mapGetters } from 'vuex'
  89. const defaultForm = { id: null, fondsId: null, collectionFloor: null, collectionName: null, collectionCode: null, collectionExplain: null }
  90. export default {
  91. name: 'CollectionLocation',
  92. components: { crudOperation, rrOperation, pagination },
  93. cruds() {
  94. return CRUD({ title: '馆藏地', url: 'api/bookBasice/initCollectionLocationList', crudMethod: { ...crudBookBasice }, sort: [], optShow: {
  95. add: true,
  96. edit: true,
  97. del: false,
  98. download: false,
  99. group: false,
  100. reset: true
  101. }})
  102. },
  103. mixins: [presenter(), header(), form(defaultForm), crud()],
  104. data() {
  105. return {
  106. permission: {
  107. add: ['admin', 'collectionLocation:add'],
  108. edit: ['admin', 'collectionLocation:edit'],
  109. del: ['admin', 'collectionLocation:del']
  110. },
  111. rules: {
  112. collectionFloor: [
  113. { required: true, message: '所在楼层不可为空', trigger: 'blur' }
  114. ],
  115. collectionName: [
  116. { required: true, message: '馆藏名不可为空', trigger: 'blur' }
  117. ]
  118. }
  119. }
  120. },
  121. computed: {
  122. ...mapGetters([
  123. 'baseApi',
  124. 'user'
  125. ])
  126. },
  127. created() {
  128. },
  129. methods: {
  130. [CRUD.HOOK.beforeRefresh]() {
  131. },
  132. // 提交前的验证
  133. [CRUD.HOOK.afterValidateCU](crud) {
  134. crud.form.fondsId = this.user.fonds.id
  135. console.log(crud.form)
  136. return true
  137. },
  138. [CRUD.HOOK.afterAddCancel]() {
  139. },
  140. [CRUD.HOOK.afterSubmit]() {
  141. },
  142. toDelete(datas) {
  143. this.$confirm('此操作将删除当前所选馆藏地<span>你是否还要继续?</span>', '提示', {
  144. confirmButtonText: '继续',
  145. cancelButtonText: '取消',
  146. type: 'warning',
  147. dangerouslyUseHTMLString: true
  148. }).then(() => {
  149. this.crud.delAllLoading = true
  150. const ids = []
  151. datas.forEach(val => {
  152. ids.push(val.id)
  153. })
  154. console.log(ids)
  155. crudBookBasice.del(ids).then((res) => {
  156. this.$message({ message: res, type: 'success', offset: 8 })
  157. this.crud.delAllLoading = false
  158. this.crud.refresh()
  159. }).catch(err => {
  160. this.crud.delAllLoading = false
  161. console.log(err)
  162. })
  163. }).catch(() => {
  164. this.crud.delAllLoading = false
  165. })
  166. },
  167. doExport(data) {
  168. crud.downloadLoading = true
  169. this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', {
  170. confirmButtonText: '继续',
  171. cancelButtonText: '取消',
  172. type: 'warning',
  173. dangerouslyUseHTMLString: true
  174. }).then(() => {
  175. const ids = []
  176. data.forEach(val => {
  177. ids.push(val.id)
  178. })
  179. const params = {
  180. 'ids': ids
  181. }
  182. const fileName = '馆藏地-' + parseTime(new Date()) + '.xlsx'
  183. getBlob(this.baseApi + '/api/bookBasice/exportCollectionLocation' + '?' + qs.stringify(params, { indices: false }), function(blob) {
  184. saveAs(blob, fileName)
  185. })
  186. }).catch(() => {
  187. })
  188. },
  189. clickRowHandler(row) {
  190. this.$refs.table.clearSelection()
  191. this.$refs.table.toggleRowSelection(row)
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .select-btn{
  198. display: inline-block;
  199. padding: 4px 11px 4px 14px;
  200. font-size: 18px;
  201. color: #fff;
  202. background: #0348F3;
  203. border-radius: 3px;
  204. margin: 10px 0 0 100px;
  205. text-align: center;
  206. cursor: pointer;
  207. }
  208. .send-obj{
  209. width: 580px;
  210. height: 180px;
  211. padding: 0 10px;
  212. border-radius: 3px 3px 3px 3px;
  213. border: 1px solid #E6E8ED;
  214. .el-tag{
  215. margin-right: 10px;
  216. }
  217. }
  218. ::v-deep .crud-opts-left{
  219. position: relative;
  220. }
  221. .double-click-btn{
  222. top: 4px !important;
  223. right: 0;
  224. left: -156px !important;
  225. }
  226. </style>