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

464 lines
17 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
3 weeks ago
3 years ago
3 years ago
2 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
3 years ago
3 weeks 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. add: ['admin', 'fonds:add'],
  175. edit: ['admin', 'fonds:edit'],
  176. del: ['admin', 'fonds:del']
  177. },
  178. rules: {
  179. fondsNo: [
  180. { required: true, message: '请输入全宗号', trigger: 'blur' }
  181. ],
  182. fondsName: [
  183. { required: true, message: '请输入全宗名称', trigger: 'blur' }
  184. ],
  185. fondsNameAbbr: [
  186. { required: true, message: '请输入全宗简称', trigger: 'blur' }
  187. ],
  188. fondsOrders: [
  189. { required: true, message: '请输入排序', trigger: 'blur', type: 'number' }
  190. ],
  191. fondsStatus: [
  192. { required: true, message: '请选择状态', trigger: 'change' }
  193. ]
  194. },
  195. enabledTypeOptions: [
  196. { key: '1', display_name: '启用' },
  197. { key: '0', display_name: '停用' }
  198. ],
  199. blurryTime: null,
  200. deleteData: [], // 删除选中的data
  201. chooseNode: null,
  202. categoryTreeData: []
  203. }
  204. },
  205. computed: {
  206. ...mapGetters([
  207. 'baseApi'
  208. ])
  209. },
  210. created() {
  211. },
  212. mounted() {
  213. FetchCategoryMenu().then(res => {
  214. this.categoryDatas = this.filterData(res)
  215. })
  216. },
  217. methods: {
  218. getCategoryDataList(node, resolve) {
  219. console.log('node', node)
  220. console.log('node.childNodes', node.childNodes)
  221. FetchCategoryMenuChildren(node.data.id ? node.data.id : 0).then(res => {
  222. if (res.length !== 0 && res[0].isType === 3) {
  223. return resolve([])
  224. }
  225. resolve(res)
  226. })
  227. },
  228. filterData(data) {
  229. return data.filter(node => {
  230. this.$set(node, 'isChecked', false)
  231. if (node.children && node.children.length > 0) {
  232. node.children = this.filterData(node.children) // 递归处理子节点
  233. }
  234. return node.isType !== 3 // 过滤掉isType为3的节点
  235. })
  236. },
  237. // getCategoryDataList(node, resolve) {
  238. // resolve(this.categoryTreeData)
  239. // },
  240. [CRUD.HOOK.beforeRefresh]() {
  241. if (this.blurryTime) {
  242. this.crud.query.startTime = this.blurryTime[0]
  243. this.crud.query.endTime = this.blurryTime[1]
  244. }
  245. },
  246. [CRUD.HOOK.afterRefresh]() {
  247. this.$refs.category.setCheckedKeys([])
  248. },
  249. // 新增前
  250. [CRUD.HOOK.beforeToAdd](crud, form) {
  251. },
  252. // 编辑前
  253. [CRUD.HOOK.beforeToEdit](crud, form) {
  254. form.id = form.fondsId
  255. },
  256. // 提交前做的操作
  257. [CRUD.HOOK.afterValidateCU](crud) {
  258. },
  259. // 触发单选
  260. handleCurrentChange(val) {
  261. if (val) {
  262. const _this = this
  263. // 清空菜单的选中
  264. this.$refs.category.setCheckedKeys([])
  265. // 保存当前的角色id
  266. this.currentId = val.fondsId
  267. console.log('val', val)
  268. console.log('this.currentId', this.currentId)
  269. console.log('this.categoryDatas', this.categoryDatas)
  270. this.categoryIds = []
  271. // this.categoryDatas.forEach(function(data) {
  272. // _this.categoryIds.push(data.id)
  273. // })
  274. // console.log(_this.categoryIds)
  275. crudfonds.FetchFondsDetail({ id: this.currentId }).then((res) => {
  276. if (res.categorys) {
  277. res.categorys.forEach(function(data) {
  278. _this.categoryIds.push(data.id)
  279. })
  280. this.$refs.category.setCheckedKeys(_this.categoryIds)
  281. }
  282. console.log(_this.categoryIds)
  283. }).catch(err => {
  284. console.log(err)
  285. })
  286. this.showButton = true
  287. }
  288. },
  289. toDelete(datas) {
  290. this.deleteData = datas
  291. this.$confirm('此操作将删除当前所选' + this.crud.title + '<span>你是否还要继续?</span>', '提示', {
  292. confirmButtonText: '继续',
  293. cancelButtonText: '取消',
  294. type: 'warning',
  295. dangerouslyUseHTMLString: true
  296. }).then(() => {
  297. this.crud.delAllLoading = true
  298. const ids = []
  299. this.deleteData.forEach(val => {
  300. ids.push(val.fondsId)
  301. })
  302. crudfonds.del(ids).then((res) => {
  303. console.log('res', res)
  304. if (res !== 0) {
  305. this.$message({ message: '删除成功', type: 'success', offset: 8 })
  306. } else {
  307. this.$message({ message: '删除失败', type: 'error', offset: 8 })
  308. }
  309. this.crud.delAllLoading = false
  310. this.crud.refresh()
  311. }).catch(err => {
  312. this.crud.delAllLoading = false
  313. console.log(err)
  314. })
  315. }).catch(() => {
  316. })
  317. },
  318. changeStatus(data, val) {
  319. data.id = data.fondsId
  320. this.$confirm('此操作将禁用 / 启用全宗 “' + data.fondsName + '”' + '<span>你是否还要继续?</span>', '提示', {
  321. confirmButtonText: '继续',
  322. cancelButtonText: '取消',
  323. type: 'warning',
  324. dangerouslyUseHTMLString: true
  325. }).then(() => {
  326. crudfonds.FetchUpdateFondsStatus(data).then(res => {
  327. this.$message({ message: '修改成功', type: 'success', offset: 8 })
  328. }).catch(() => {
  329. data.fondsStatus = !data.fondsStatus
  330. })
  331. }).catch(() => {
  332. this.$message({ message: '已取消修改', offset: 8 })
  333. data.fondsStatus = data.fondsStatus ? 0 : 1
  334. })
  335. },
  336. doExport(data) {
  337. crud.downloadLoading = true
  338. this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', {
  339. confirmButtonText: '继续',
  340. cancelButtonText: '取消',
  341. type: 'warning',
  342. dangerouslyUseHTMLString: true
  343. }).then(() => {
  344. const ids = []
  345. data.forEach(val => {
  346. ids.push(val.fondsId)
  347. })
  348. const params = {
  349. 'fondsIds': ids
  350. }
  351. exportFile(this.baseApi + '/api/fonds/download?' + qs.stringify(params, { indices: false }))
  352. }).catch(() => {
  353. })
  354. },
  355. findNodeById(id, nodes) {
  356. for (const node of nodes) {
  357. if (node.id === id) {
  358. return node
  359. } else if (node.children.length > 0) {
  360. const foundNode = this.findNodeById(id, node.children)
  361. if (foundNode) {
  362. return foundNode
  363. }
  364. }
  365. }
  366. return null
  367. },
  368. getAllChildIds(id, nodes) {
  369. const node = this.findNodeById(id, nodes)
  370. if (node) {
  371. let childIds = [node.id]
  372. for (const child of node.children) {
  373. childIds = childIds.concat(this.getAllChildIds(child.id, nodes))
  374. }
  375. return childIds
  376. } else {
  377. return []
  378. }
  379. },
  380. categoryChange(categorys) {
  381. console.log('categorys.id', categorys.id)
  382. // console.log(this.categoryDatas)
  383. // const childrenIds = this.getAllChildIds(categorys.id, this.categoryDatas)
  384. // console.log('childrenIds', childrenIds)
  385. // console.log(this.$refs.category.getCheckedKeys())
  386. // this.categoryIds = this.$refs.category.getCheckedKeys()
  387. FetchCategoryMenuChildren(categorys.id).then(childIds => {
  388. const i = this.categoryIds.indexOf(categorys.id)
  389. if (i !== -1) {
  390. this.categoryIds.splice(i, 1)
  391. for (let i = 0; i < childIds.length; i++) {
  392. const index = this.categoryIds.indexOf(childIds[i].id)
  393. if (index !== -1) {
  394. this.categoryIds.splice(index, 1)
  395. }
  396. }
  397. } else {
  398. this.categoryIds.push(categorys.id)
  399. for (let i = 0; i < childIds.length; i++) {
  400. const index = this.categoryIds.indexOf(childIds[i].id)
  401. if (index === -1) {
  402. this.categoryIds.push(childIds[i].id)
  403. }
  404. }
  405. }
  406. this.$refs.category.setCheckedKeys(this.categoryIds)
  407. })
  408. },
  409. // 保存菜单
  410. saveCategory() {
  411. this.categoryLoading = true
  412. const fonds = { id: this.currentId, categorys: [] }
  413. // 得到已选中的 key 值
  414. this.categoryIds.forEach(function(id) {
  415. const categorys = { id: id }
  416. fonds.categorys.push(categorys)
  417. })
  418. console.log(fonds)
  419. crudfonds.FetchFondsCategory(fonds).then(() => {
  420. this.$message({ message: '保存成功', type: 'success', offset: 8 })
  421. this.categoryLoading = false
  422. this.update()
  423. }).catch(err => {
  424. this.categoryLoading = false
  425. console.log(err.response.data.message)
  426. })
  427. },
  428. // 改变数据
  429. update() {
  430. // 无刷新更新 表格数据
  431. crudfonds.FetchInitFondsList().then(res => {
  432. console.log(res)
  433. for (let i = 0; i < this.crud.data.length; i++) {
  434. if (res.fondsId === this.crud.data[i].fondsId) {
  435. this.crud.data[i] = res
  436. break
  437. }
  438. }
  439. })
  440. }
  441. }
  442. }
  443. </script>
  444. <style lang="scss" scoped>
  445. .group-form{
  446. .el-form-item{
  447. &:nth-child(odd){
  448. margin-right: 0;
  449. }
  450. &.form-item-style{
  451. margin-right: 40px;
  452. }
  453. }
  454. }
  455. .tree-tab span.role-span.role-tab-active{
  456. border-bottom: none;
  457. }
  458. </style>