交通管理局公文项目
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.

353 lines
13 KiB

1 month ago
3 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
3 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <div class="app-container row-container">
  3. <!--工具栏-->
  4. <div class="head-container">
  5. <div class="head-search">
  6. <!-- 搜索 -->
  7. <el-input v-model="query.search" clearable size="small" placeholder="输入借阅者名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  8. <rrOperation />
  9. </div>
  10. <div style="display: flex; justify-content: space-between;">
  11. <crudOperation :permission="permission">
  12. <!-- <template v-slot:middle>
  13. <el-button size="mini" :disabled="crud.selections.length !== 1" @click="toEdit(crud.selections[0])">
  14. <i class="iconfont icon-bianji" />
  15. 编辑
  16. </el-button>
  17. </template> -->
  18. <template v-slot:right>
  19. <el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)">
  20. <i class="iconfont icon-daochu" />
  21. 导出
  22. </el-button>
  23. <el-button icon="el-icon-refresh-left" size="mini" :disabled="crud.selections.length !== 1" @click="handlePwdReset(crud.selections)">密码重置</el-button>
  24. </template>
  25. </crudOperation>
  26. <div>
  27. <el-button size="mini" :loading="bindLoading" :disabled="crud.selections.length !== 1" @click="bindingTag(crud.selections)">
  28. <i class="iconfont icon-bendiguajie" />
  29. 绑定借阅证
  30. </el-button>
  31. <el-button :loading="unbindBtnLoading" class="unbind-btn" size="mini" :disabled="crud.selections.length !== 1" @click="handleUnbind(crud.selections)">
  32. <i class="iconfont icon-jiebang" />
  33. 解绑借阅证
  34. </el-button>
  35. </div>
  36. </div>
  37. </div>
  38. <!--表格渲染-->
  39. <div class="container-wrap">
  40. <span class="right-top-line" />
  41. <span class="left-bottom-line" />
  42. <el-table
  43. ref="table"
  44. v-loading="crud.loading"
  45. :data="crud.data"
  46. row-key="id"
  47. @select="crud.selectChange"
  48. @select-all="crud.selectAllChange"
  49. @selection-change="crud.selectionChangeHandler"
  50. >
  51. <el-table-column type="selection" width="55" align="center" />
  52. <el-table-column prop="borrowName" label="借阅者名称" />
  53. <el-table-column prop="borrowType" label="借阅者类型">
  54. <template slot-scope="scope">
  55. <div>
  56. <span v-if="scope.row.borrowType === 1">部门</span>
  57. <span v-if="scope.row.borrowType === 2">个人</span>
  58. </div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="borrowNo" label="借阅证绑定">
  62. <template slot-scope="scope">
  63. <div>
  64. <span v-if="scope.row.borrowNo === null || scope.row.borrowNo === ''" class="row-state cancel-state">未绑定</span>
  65. <span v-else class="row-state end-state">已绑定</span>
  66. </div>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="borrowNo" label="借阅证号" />
  70. <el-table-column prop="create_time" label="创建日期" width="200px">
  71. <template slot-scope="scope">
  72. <div>{{ scope.row.create_time | parseTime }}</div>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination v-if="crud.data.length !== 0" />
  77. </div>
  78. <!--表单渲染-->
  79. <el-dialog class="borrower-dialog" append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title">
  80. <div class="setting-dialog">
  81. <el-form ref="form" inline :model="form" :rules="rules" size="small" label-width="100px">
  82. <el-form-item label="借阅者类型" prop="borrowType">
  83. <el-radio-group v-model="form.borrowType">
  84. <el-radio :label="1">部门</el-radio>
  85. <el-radio :label="2">个人</el-radio>
  86. </el-radio-group>
  87. </el-form-item>
  88. <el-form-item label="借阅者名称" prop="borrowName">
  89. <el-input v-model="form.borrowName" style="width:380px;" />
  90. </el-form-item>
  91. <el-form-item label="借阅证号" prop="borrowNo">
  92. <el-input v-model="form.borrowNo" disabled style="width:380px;" />
  93. </el-form-item>
  94. <el-form-item label="备注" prop="remarks">
  95. <el-input v-model="form.remarks" type="textarea" :rows="4" style="width:380px;" />
  96. </el-form-item>
  97. </el-form>
  98. <div slot="footer" class="dialog-footer">
  99. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  100. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确定</el-button>
  101. </div>
  102. </div>
  103. </el-dialog>
  104. <!-- 密码重置dialog -->
  105. <el-dialog class="tip-dialog" :visible.sync="resetVisible" :modal-append-to-body="false" append-to-body :close-on-click-modal="false" title="提示">
  106. <div class="setting-dialog">
  107. <div class="tip-content">
  108. <p class="tipMsg">此操作将重置所选借阅者密码为"123456"</p>
  109. <span>你是否还要继续?</span>
  110. </div>
  111. <div slot="footer" class="dialog-footer">
  112. <el-button type="text" @click="resetVisible = false">取消</el-button>
  113. <el-button v-loading="btnLoading" type="primary" @click="pwdReset(crud.selections)">继续</el-button>
  114. </div>
  115. </div>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import crudBorrower from '@/api/system/borrower'
  121. import { FetchReadPatron, FetchBindReadNo, FetchUnbindReadNo } from '@/api/system/documentArchives'
  122. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  123. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  124. import rrOperation from '@crud/RR.operation'
  125. import crudOperation from '@crud/CRUD.operation'
  126. import pagination from '@crud/Pagination'
  127. import { exportFile } from '@/utils/index'
  128. import qs from 'qs'
  129. import { mapGetters } from 'vuex'
  130. // crud交由presenter持有
  131. const defaultForm = { id: null, borrowType: 1, borrowName: null, remarks: null }
  132. export default {
  133. name: 'BorrowerManage',
  134. components: { crudOperation, rrOperation, pagination },
  135. cruds() {
  136. return CRUD({
  137. title: '借阅者',
  138. url: 'api/documentArchives/initBorrowerList',
  139. crudMethod: { ...crudBorrower },
  140. optShow: {
  141. add: true,
  142. edit: true,
  143. del: true,
  144. reset: true,
  145. download: false,
  146. group: false
  147. }
  148. })
  149. },
  150. mixins: [presenter(), header(), form(defaultForm), crud()],
  151. data() {
  152. return {
  153. permission: {
  154. add: ['admin', 'borrower:add'],
  155. edit: ['admin', 'borrower:edit'],
  156. del: ['admin', 'borrower:del']
  157. },
  158. rules: {
  159. borrowType: [
  160. { required: true, message: '请选择借阅者类型', trigger: 'change' }
  161. ],
  162. borrowName: [
  163. { required: true, message: '借阅者名称不可为空', trigger: 'blur' }
  164. ]
  165. },
  166. bindLoading: false,
  167. unbindBtnLoading: false,
  168. resetVisible: false,
  169. btnLoading: false
  170. }
  171. },
  172. computed: {
  173. ...mapGetters([
  174. 'baseApi'
  175. ])
  176. },
  177. created() {
  178. },
  179. mounted() {
  180. },
  181. methods: {
  182. [CRUD.HOOK.afterRefresh](crud) {
  183. },
  184. bindingTag(selection) {
  185. this.bindLoading = true
  186. console.log('selection', selection)
  187. if (selection[0].borrowNo && (selection[0].borrowNo !== '' || selection[0].borrowNo !== null)) {
  188. console.log('当前用户已绑定')
  189. this.$confirm('当前所选用户已有借阅证' + '<span>你是否还要继续?</span>', '提示', {
  190. confirmButtonText: '重新绑定',
  191. cancelButtonText: '取消',
  192. type: 'warning',
  193. dangerouslyUseHTMLString: true
  194. }).then(() => {
  195. this.handlBind(selection)
  196. }).catch(() => {
  197. this.bindLoading = false
  198. })
  199. } else {
  200. this.handlBind(selection)
  201. }
  202. },
  203. handlBind(selection) {
  204. const sDevID = process.env.NODE_ENV === 'production' ? window.g.sDevID : process.env.VUE_APP_SDEVID
  205. const param = {
  206. 'sDevID': sDevID
  207. }
  208. FetchReadPatron(param).then((res) => {
  209. console.log('res', res)
  210. if (!res) {
  211. this.$message({ message: '绑定失败', type: 'error', offset: 8 })
  212. this.bindLoading = false
  213. } else {
  214. const result = JSON.parse(res)
  215. console.log('result', result)
  216. if (result.code === '0') {
  217. const readParam = {
  218. 'id': selection[0].id,
  219. 'borrowNo': result.data[0].barcode
  220. }
  221. FetchBindReadNo(readParam).then((res) => {
  222. console.log('FetchBindReadNo', res)
  223. this.crud.refresh()
  224. this.bindLoading = false
  225. this.$message({ message: '绑定成功', type: 'success', offset: 8 })
  226. }).catch(error => {
  227. console.error(error)
  228. this.bindLoading = false
  229. })
  230. } else if (result.code === '-1') {
  231. this.$message({ message: result.message, type: 'error', offset: 8 })
  232. this.bindLoading = false
  233. } else if (result.code === '-1000') {
  234. // 读写器超时未响应
  235. this.$message({ message: result.message, type: 'error', offset: 8 })
  236. this.bindLoading = false
  237. }
  238. }
  239. }).catch(error => {
  240. console.error(error)
  241. this.bindLoading = false
  242. })
  243. },
  244. handleUnbind(selection) {
  245. if (selection[0].borrowNo && (selection[0].borrowNo !== '' || selection[0].borrowNo !== null)) {
  246. this.$confirm('此操作将解除所选借阅证的绑定关系' + '<span>你是否还要继续?</span>', '提示', {
  247. confirmButtonText: '继续',
  248. cancelButtonText: '取消',
  249. type: 'warning',
  250. dangerouslyUseHTMLString: true
  251. }).then(() => {
  252. this.unbindBtnLoading = true
  253. const unbindData = {
  254. 'id': selection[0].id,
  255. 'borrowNo': selection[0].borrowNo
  256. }
  257. FetchUnbindReadNo(unbindData).then((res) => {
  258. this.unbindBtnLoading = false
  259. this.$message({ message: '解除绑定成功', type: 'success', offset: 8 })
  260. this.crud.refresh()
  261. })
  262. }).catch(() => {
  263. })
  264. } else {
  265. this.$message({ message: '当前所选用户借阅者未绑定', type: 'error', offset: 8 })
  266. }
  267. },
  268. doExport(data) {
  269. console.log(data)
  270. crud.downloadLoading = true
  271. this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', {
  272. confirmButtonText: '继续',
  273. cancelButtonText: '取消',
  274. type: 'warning',
  275. dangerouslyUseHTMLString: true
  276. }).then(() => {
  277. const ids = []
  278. data.forEach(val => {
  279. ids.push(val.id)
  280. })
  281. const params = {
  282. 'ids': ids
  283. }
  284. console.log('params', params)
  285. exportFile(this.baseApi + '/api/documentArchives/downloadBorrower?' + qs.stringify(params, { indices: false }))
  286. }).catch(() => {
  287. })
  288. },
  289. normalizer(node) {
  290. if (node.children && !node.children.length) {
  291. delete node.children
  292. }
  293. return {
  294. id: node.id,
  295. label: node.cnName,
  296. children: node.children,
  297. isDisabled: node.isType !== 2
  298. }
  299. },
  300. // 重置密码
  301. handlePwdReset() {
  302. this.resetVisible = true
  303. },
  304. // 重置密码
  305. pwdReset(data) {
  306. const params = data.map(item => { return item.borrowName })
  307. console.log('params', params)
  308. // this.btnLoading = true
  309. // resetpassword(params).then(res => {
  310. // if (res === 'SUCCESS') {
  311. // this.$message({ message: '重置密码成功', type: 'success', offset: 8 })
  312. // this.resetVisible = false
  313. // this.btnLoading = false
  314. // this.crud.refresh()
  315. // } else {
  316. // this.$message({ message: '重置密码失败', type: 'error', offset: 8 })
  317. // this.btnLoading = false
  318. // }
  319. // })
  320. }
  321. }
  322. }
  323. </script>
  324. <style lang="scss" scoped>
  325. [data-theme=light] .el-button.unbind-btn,
  326. [data-theme=light] .el-button.unbind-btn:hover,
  327. [data-theme=light] .el-button.unbind-btn:focus{
  328. color: #ED4A41;
  329. border-color: #ED4A41;
  330. background: transparent;
  331. }
  332. [data-theme=light] .el-button.unbind-btn.is-disabled,
  333. [data-theme=light] .el-button.unbind-btn.is-disabled:hover,
  334. [data-theme=light] .el-button.unbind-btn.is-disabled:focus{
  335. color:#F6A5A0;
  336. border-color:#F6A5A0;
  337. background: rgba(252,49,49,0.2);
  338. }
  339. .borrower-dialog{
  340. ::v-deep .el-dialog{
  341. width: 550px !important;
  342. }
  343. }
  344. </style>