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

488 lines
18 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
3 years ago
3 years ago
3 years ago
3 years ago
2 months ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 weeks ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 months ago
2 months ago
2 months ago
3 years ago
3 years ago
2 months ago
3 years ago
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="app-container">
  3. <div class="container-main" style="justify-content: flex-start;">
  4. <!--侧边部门数据-->
  5. <div class="elect-cont-right">
  6. <!--工具栏-->
  7. <div class="head-container">
  8. <div v-if="crud.props.searchToggle" class="head-search">
  9. <!-- 搜索 -->
  10. <el-input v-model="query.blurry" size="small" clearable placeholder="输入全宗名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  11. <date-range-picker v-model="blurryTime" class="date-item" />
  12. <el-select v-model="query.status" clearable size="small" placeholder="状态" class="filter-item" style="width: 100px" @change="crud.toQuery">
  13. <i slot="prefix" class="iconfont icon-zhuangtai" />
  14. <el-option v-for="item in enabledTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
  15. </el-select>
  16. <rrOperation />
  17. </div>
  18. <crudOperation :permission="permission">
  19. <template v-slot:middle>
  20. <el-button slot="reference" size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)">
  21. <i class="iconfont icon-shanchu" />
  22. 删除
  23. </el-button>
  24. </template>
  25. <template v-slot:right>
  26. <el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)">
  27. <i class="iconfont icon-daochu" />
  28. 导出
  29. </el-button>
  30. </template>
  31. </crudOperation>
  32. </div>
  33. <div class="container-right">
  34. <span class="right-top-line" />
  35. <span class="left-bottom-line" />
  36. <!-- 表单渲染 -->
  37. <el-dialog :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" class="group-form">
  38. <span class="dialog-right-top" />
  39. <span class="dialog-left-bottom" />
  40. <div class="setting-dialog">
  41. <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="90px">
  42. <el-row>
  43. <el-form-item label="全宗号" prop="fondsNo">
  44. <el-input v-model="form.fondsNo" />
  45. </el-form-item>
  46. </el-row>
  47. <el-form-item label="全宗名称" prop="fondsName" class="form-item-style">
  48. <el-input v-model="form.fondsName" />
  49. </el-form-item>
  50. <el-form-item label="全宗简称" prop="fondsNameAbbr">
  51. <el-input v-model="form.fondsNameAbbr" />
  52. </el-form-item>
  53. <el-form-item label="排序" prop="fondsOrders" class="form-item-style">
  54. <el-input-number
  55. v-model.number="form.fondsOrders"
  56. :min="0"
  57. :max="999"
  58. controls-position="right"
  59. />
  60. </el-form-item>
  61. <el-form-item label="状态" prop="fondsStatus">
  62. <el-radio-group v-model="form.fondsStatus">
  63. <el-radio :label="1">启用</el-radio>
  64. <el-radio :label="0">停用</el-radio>
  65. </el-radio-group>
  66. </el-form-item>
  67. <el-form-item label="备注" prop="fondsRemarks">
  68. <el-input v-model="form.fondsRemarks" style="width: 586px;" rows="5" type="textarea" />
  69. </el-form-item>
  70. </el-form>
  71. <div slot="footer" class="dialog-footer">
  72. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  73. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确定</el-button>
  74. </div>
  75. </div>
  76. </el-dialog>
  77. <el-table ref="table" v-loading="crud.loading" highlight-current-row style="width: 100%;" :data="crud.data" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
  78. <el-table-column type="selection" align="center" width="55" />
  79. <el-table-column prop="fondsNo" label="全宗号" />
  80. <el-table-column prop="fondsName" label="全宗名称" min-width="120" />
  81. <el-table-column prop="deptsCount" label="部门" />
  82. <el-table-column prop="fondsOrders" label="排序" />
  83. <el-table-column label="状态" align="center" prop="fondsStatus" width="60">
  84. <template slot-scope="scope">
  85. <el-switch v-model="scope.row.fondsStatus" active-color="#409EFF" inactive-color="#F56C6C" :active-value="1" :inactive-value="0" @change="changeStatus(scope.row, scope.row.fondsStatus)" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期">
  89. <template slot-scope="scope">
  90. <div>{{ scope.row.createTime | parseTime }}</div>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <!--分页组件-->
  95. <pagination />
  96. </div>
  97. </div>
  98. <div class="elect-cont-left role-cont-left" style="margin: 0 0 0 20px;">
  99. <div class="container-left">
  100. <span class="right-top-line" />
  101. <span class="left-bottom-line" />
  102. <div slot="header" class="tree-tab">
  103. <el-tooltip class="item" effect="dark" content="选择门类关联" placement="top">
  104. <span class="role-span role-tab-active">门类关联</span>
  105. </el-tooltip>
  106. <!-- v-permission="['admin','fonds:edit']" -->
  107. <el-button
  108. :disabled="!showButton"
  109. :loading="categoryLoading"
  110. size="mini"
  111. @click="saveCategory"
  112. >保存</el-button>
  113. </div>
  114. <!-- :load="getCategoryDataList" @check="menuChange" default-expand-all :default-checked-keys="categoryIds"-->
  115. <el-tree
  116. ref="category"
  117. lazy
  118. :data="categoryDatas"
  119. :load="getCategoryDataList"
  120. :default-checked-keys="categoryIds"
  121. check-strictly
  122. show-checkbox
  123. node-key="id"
  124. highlight-current
  125. :props="defaultProps"
  126. @check="categoryChange"
  127. />
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import crudfonds from '@/api/system/fonds'
  135. import { FetchCategoryMenu, FetchCategoryMenuChildren } from '@/api/system/category/category'
  136. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  137. import rrOperation from '@crud/RR.operation'
  138. import crudOperation from '@crud/CRUD.operation'
  139. import pagination from '@crud/Pagination'
  140. import DateRangePicker from '@/components/DateRangePicker'
  141. import { exportFile } from '@/utils/index'
  142. import qs from 'qs'
  143. import { mapGetters } from 'vuex'
  144. const defaultForm = { id: null, fondsName: null, fondsNameAbbr: null, fondsNo: null, fondsOrders: 999, fondsStatus: null, fondsRemarks: null }
  145. export default {
  146. name: 'Group',
  147. components: { pagination, crudOperation, rrOperation, DateRangePicker },
  148. cruds() {
  149. return CRUD({ title: '全宗', idField: 'fondsId', url: 'api/fonds/initFondsList', sort: 'update_time,asc', crudMethod: { ...crudfonds }, optShow: {
  150. add: true,
  151. edit: true,
  152. del: false,
  153. reset: true,
  154. download: false,
  155. group: false
  156. }})
  157. },
  158. mixins: [presenter(), header(), form(defaultForm), crud()],
  159. data() {
  160. return {
  161. defaultProps: {
  162. children: 'children',
  163. label: 'cnName',
  164. isLeaf: (data, node) => {
  165. if (data.isType === 2) {
  166. return true
  167. }
  168. }
  169. },
  170. currentId: 0, categoryLoading: false, showButton: false,
  171. categoryDatas: [], categoryIds: [], depts: [], deptDatas: [], // 多选时使用
  172. categoryAllData: [],
  173. permission: {},
  174. rules: {
  175. fondsNo: [
  176. { required: true, message: '请输入全宗号', trigger: 'blur' }
  177. ],
  178. fondsName: [
  179. { required: true, message: '请输入全宗名称', trigger: 'blur' }
  180. ],
  181. fondsNameAbbr: [
  182. { required: true, message: '请输入全宗简称', trigger: 'blur' }
  183. ],
  184. fondsOrders: [
  185. { required: true, message: '请输入排序', trigger: 'blur', type: 'number' }
  186. ],
  187. fondsStatus: [
  188. { required: true, message: '请选择状态', trigger: 'change' }
  189. ]
  190. },
  191. enabledTypeOptions: [
  192. { key: '1', display_name: '启用' },
  193. { key: '0', display_name: '停用' }
  194. ],
  195. blurryTime: null,
  196. deleteData: [], // 删除选中的data
  197. chooseNode: null,
  198. categoryTreeData: []
  199. }
  200. },
  201. computed: {
  202. ...mapGetters([
  203. 'baseApi'
  204. ])
  205. },
  206. activated() {
  207. this.categoryDatas = []
  208. this.categoryIds = []
  209. this.$refs.category && this.$refs.category.setCheckedKeys([])
  210. this.$refs.category && this.$refs.category.clearChecked()
  211. this.$refs.category && this.$refs.category.doLayout()
  212. FetchCategoryMenu().then(res => {
  213. this.categoryDatas = this.filterData(res)
  214. }).catch(err => {
  215. console.error('请求根节点数据失败:', err)
  216. this.categoryDatas = []
  217. })
  218. },
  219. deactivated() {
  220. this.categoryDatas = []
  221. this.categoryIds = []
  222. this.currentId = 0
  223. this.showButton = false
  224. this.$refs.category && this.$refs.category.setCheckedKeys([])
  225. this.$refs.category && this.$refs.category.clearChecked()
  226. },
  227. beforeDestroy() {
  228. this.categoryDatas = []
  229. this.categoryIds = []
  230. this.$refs.category = null
  231. },
  232. created() {
  233. },
  234. mounted() {
  235. // FetchCategoryMenu().then(res => {
  236. // this.categoryDatas = this.filterData(res)
  237. // })
  238. },
  239. methods: {
  240. getCategoryDataList(node, resolve) {
  241. console.log('node', node)
  242. console.log('node.childNodes', node.childNodes)
  243. FetchCategoryMenuChildren(node.data.id ? node.data.id : 0).then(res => {
  244. if (res.length !== 0 && res[0].isType === 3) {
  245. return resolve([])
  246. }
  247. resolve(res)
  248. })
  249. },
  250. filterData(data) {
  251. return data.filter(node => {
  252. this.$set(node, 'isChecked', false)
  253. if (node.children && node.children.length > 0) {
  254. node.children = this.filterData(node.children) // 递归处理子节点
  255. }
  256. return node.isType !== 3 // 过滤掉isType为3的节点
  257. })
  258. },
  259. // getCategoryDataList(node, resolve) {
  260. // resolve(this.categoryTreeData)
  261. // },
  262. [CRUD.HOOK.beforeRefresh]() {
  263. if (this.blurryTime) {
  264. this.crud.query.startTime = this.blurryTime[0]
  265. this.crud.query.endTime = this.blurryTime[1]
  266. }
  267. },
  268. [CRUD.HOOK.afterRefresh]() {
  269. this.$refs.category.setCheckedKeys([])
  270. },
  271. // 新增前
  272. [CRUD.HOOK.beforeToAdd](crud, form) {
  273. },
  274. // 编辑前
  275. [CRUD.HOOK.beforeToEdit](crud, form) {
  276. form.id = form.fondsId
  277. },
  278. // 提交前做的操作
  279. [CRUD.HOOK.afterValidateCU](crud) {
  280. },
  281. // 触发单选
  282. handleCurrentChange(val) {
  283. if (val) {
  284. const _this = this
  285. // 清空菜单的选中
  286. this.$refs.category.setCheckedKeys([])
  287. // 保存当前的角色id
  288. this.currentId = val.fondsId
  289. console.log('val', val)
  290. console.log('this.currentId', this.currentId)
  291. console.log('this.categoryDatas', this.categoryDatas)
  292. this.categoryIds = []
  293. // this.categoryDatas.forEach(function(data) {
  294. // _this.categoryIds.push(data.id)
  295. // })
  296. // console.log(_this.categoryIds)
  297. crudfonds.FetchFondsDetail({ id: this.currentId }).then((res) => {
  298. if (res.categorys) {
  299. res.categorys.forEach(function(data) {
  300. _this.categoryIds.push(data.id)
  301. })
  302. this.$refs.category.setCheckedKeys(_this.categoryIds)
  303. }
  304. console.log(_this.categoryIds)
  305. }).catch(err => {
  306. console.log(err)
  307. })
  308. this.showButton = true
  309. }
  310. },
  311. toDelete(datas) {
  312. this.deleteData = datas
  313. this.$confirm('此操作将删除当前所选' + this.crud.title + '<span>你是否还要继续?</span>', '提示', {
  314. confirmButtonText: '继续',
  315. cancelButtonText: '取消',
  316. type: 'warning',
  317. dangerouslyUseHTMLString: true
  318. }).then(() => {
  319. this.crud.delAllLoading = true
  320. const ids = []
  321. this.deleteData.forEach(val => {
  322. ids.push(val.fondsId)
  323. })
  324. crudfonds.del(ids).then((res) => {
  325. console.log('res', res)
  326. if (res !== 0) {
  327. this.$message({ message: '删除成功', type: 'success', offset: 8 })
  328. } else {
  329. this.$message({ message: '删除失败', type: 'error', offset: 8 })
  330. }
  331. this.crud.delAllLoading = false
  332. this.crud.refresh()
  333. }).catch(err => {
  334. this.crud.delAllLoading = false
  335. console.log(err)
  336. })
  337. }).catch(() => {
  338. })
  339. },
  340. changeStatus(data, val) {
  341. data.id = data.fondsId
  342. this.$confirm('此操作将禁用 / 启用全宗 “' + data.fondsName + '”' + '<span>你是否还要继续?</span>', '提示', {
  343. confirmButtonText: '继续',
  344. cancelButtonText: '取消',
  345. type: 'warning',
  346. dangerouslyUseHTMLString: true
  347. }).then(() => {
  348. crudfonds.FetchUpdateFondsStatus(data).then(res => {
  349. this.$message({ message: '修改成功', type: 'success', offset: 8 })
  350. }).catch(() => {
  351. data.fondsStatus = !data.fondsStatus
  352. })
  353. }).catch(() => {
  354. this.$message({ message: '已取消修改', offset: 8 })
  355. data.fondsStatus = data.fondsStatus ? 0 : 1
  356. })
  357. },
  358. doExport(data) {
  359. crud.downloadLoading = true
  360. this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', {
  361. confirmButtonText: '继续',
  362. cancelButtonText: '取消',
  363. type: 'warning',
  364. dangerouslyUseHTMLString: true
  365. }).then(() => {
  366. const ids = []
  367. data.forEach(val => {
  368. ids.push(val.fondsId)
  369. })
  370. const params = {
  371. 'fondsIds': ids
  372. }
  373. exportFile(this.baseApi + '/api/fonds/download?' + qs.stringify(params, { indices: false }))
  374. }).catch(() => {
  375. })
  376. },
  377. findNodeById(id, nodes) {
  378. for (const node of nodes) {
  379. if (node.id === id) {
  380. return node
  381. } else if (node.children.length > 0) {
  382. const foundNode = this.findNodeById(id, node.children)
  383. if (foundNode) {
  384. return foundNode
  385. }
  386. }
  387. }
  388. return null
  389. },
  390. getAllChildIds(id, nodes) {
  391. const node = this.findNodeById(id, nodes)
  392. if (node) {
  393. let childIds = [node.id]
  394. for (const child of node.children) {
  395. childIds = childIds.concat(this.getAllChildIds(child.id, nodes))
  396. }
  397. return childIds
  398. } else {
  399. return []
  400. }
  401. },
  402. categoryChange(categorys) {
  403. console.log('categorys.id', categorys.id)
  404. // console.log(this.categoryDatas)
  405. // const childrenIds = this.getAllChildIds(categorys.id, this.categoryDatas)
  406. // console.log('childrenIds', childrenIds)
  407. // console.log(this.$refs.category.getCheckedKeys())
  408. // this.categoryIds = this.$refs.category.getCheckedKeys()
  409. FetchCategoryMenuChildren(categorys.id).then(childIds => {
  410. const i = this.categoryIds.indexOf(categorys.id)
  411. if (i !== -1) {
  412. this.categoryIds.splice(i, 1)
  413. for (let i = 0; i < childIds.length; i++) {
  414. const index = this.categoryIds.indexOf(childIds[i].id)
  415. if (index !== -1) {
  416. this.categoryIds.splice(index, 1)
  417. }
  418. }
  419. } else {
  420. this.categoryIds.push(categorys.id)
  421. for (let i = 0; i < childIds.length; i++) {
  422. const index = this.categoryIds.indexOf(childIds[i].id)
  423. if (index === -1) {
  424. this.categoryIds.push(childIds[i].id)
  425. }
  426. }
  427. }
  428. this.$refs.category.setCheckedKeys(this.categoryIds)
  429. })
  430. },
  431. // 保存菜单
  432. saveCategory() {
  433. this.categoryLoading = true
  434. const fonds = { id: this.currentId, categorys: [] }
  435. // 得到已选中的 key 值
  436. this.categoryIds.forEach(function(id) {
  437. const categorys = { id: id }
  438. fonds.categorys.push(categorys)
  439. })
  440. console.log(fonds)
  441. crudfonds.FetchFondsCategory(fonds).then(() => {
  442. this.$message({ message: '保存成功', type: 'success', offset: 8 })
  443. this.categoryLoading = false
  444. this.update()
  445. }).catch(err => {
  446. this.categoryLoading = false
  447. console.log(err.response.data.message)
  448. })
  449. },
  450. // 改变数据
  451. update() {
  452. // 无刷新更新 表格数据
  453. crudfonds.FetchInitFondsList().then(res => {
  454. console.log(res)
  455. for (let i = 0; i < this.crud.data.length; i++) {
  456. if (res.fondsId === this.crud.data[i].fondsId) {
  457. this.crud.data[i] = res
  458. break
  459. }
  460. }
  461. })
  462. }
  463. }
  464. }
  465. </script>
  466. <style lang="scss" scoped>
  467. .group-form{
  468. .el-form-item{
  469. &:nth-child(odd){
  470. margin-right: 0;
  471. }
  472. &.form-item-style{
  473. margin-right: 40px;
  474. }
  475. }
  476. }
  477. .tree-tab span.role-span.role-tab-active{
  478. border-bottom: none;
  479. }
  480. </style>