addUpdateMap.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <template>
  2. <rx-layout>
  3. <div slot="center" style>
  4. <div class="mainContent">
  5. <breadcrumb firstLevel="地图管理" :lastLevel="pkId ? '编辑地图' : '新增地图'" />
  6. <div class="body">
  7. <div class="content">
  8. <a-form-model ref="mapRef" :model="mapForm" :rules="mapRules" layout="inline" hideRequiredMark>
  9. <a-row :gutter="24" type="flex" style="align-items: center;">
  10. <a-col :span="12">
  11. <span class="titleBox">基础信息</span>
  12. </a-col>
  13. <a-col :span="12">
  14. <a-button class="totBtn" @click="$router.back()">取消</a-button>
  15. <a-button class="totBtn" style="margin-right: 20px;" type="primary" @click="handleSaveClick" :loading="saveLoading">保存</a-button>
  16. </a-col>
  17. </a-row>
  18. <a-form-model-item style="margin-left: 12px;" label="*地图类型:" prop="type">
  19. <a-select v-model="mapForm.type" placeholder="请选择" prop="type" :disabled="!!pkId" :showArrow="false">
  20. <a-select-option v-for="(item,index) in mapTypeList" :key="index" :value="item.value">
  21. {{item.name}}
  22. </a-select-option>
  23. </a-select>
  24. </a-form-model-item>
  25. <a-form-model-item style="margin-left: 12px;margin-bottom: 20px;" label="*地图名称:" prop="name">
  26. <a-input v-model="mapForm.name" placeholder="请输入" :maxLength="10" />
  27. </a-form-model-item>
  28. <!-- <span class="titleBox">权限信息</span> -->
  29. <a-row :gutter="24" type="flex" style="height:32px;align-items: center;">
  30. <a-col :span="12">
  31. <span class="titleBox">权限信息</span>
  32. <span v-if="pkId" style="margin-left: 19px;color: #1890ff;cursor: pointer;" @click="extend = !extend">{{ extend ? '收缩∧' : '展开∨' }}</span>
  33. </a-col>
  34. </a-row>
  35. <template v-if="!pkId || extend">
  36. <div style="margin-left: 12px;">
  37. <a-form-model-item label="*所属组织:" prop="groupId">
  38. <a-tree-select
  39. v-model="mapForm.groupId"
  40. allow-clear
  41. :dropdown-style="{ minHeight: '200px', maxHeight: '400px', overflow: 'auto' }"
  42. :tree-data="orgData"
  43. multiple
  44. placeholder="请选择"
  45. treeNodeLabelProp="label"
  46. @change="handleTreeChange"
  47. @select="handleTreeSelect"
  48. :treeDataSimpleMode="true"
  49. >
  50. </a-tree-select>
  51. </a-form-model-item>
  52. <a-form-model-item label="*阅读权限:" prop="groupPurview">
  53. <a-select v-model="mapForm.groupPurview" placeholder="请选择" :disabled="!mapForm.groupId.length" :showArrow="false">
  54. <a-select-option v-for="(item,index) in authList" :key="index" :value="item.value" >
  55. {{item.label}}
  56. </a-select-option>
  57. </a-select>
  58. </a-form-model-item>
  59. <template v-if="mapForm.groupPurview == 2">
  60. <a-form-model-item>
  61. <span slot="label">&ensp;可阅读者</span>
  62. <a-button class="totBtn" style="margin-top: 6px;float: left;" type="primary" @click="handleAddUserShow">添加员工</a-button>
  63. </a-form-model-item>
  64. <template v-if="userList.length">
  65. <!-- <rx-grid
  66. ref="peopleRef"
  67. :columns="userColumns"
  68. :dataSource="userList"
  69. :defaultPageSize="5"
  70. :heightauto="true"
  71. >
  72. <template slot="groupSummary" slot-scope="{text}">
  73. <div style="white-space: pre-line">{{ text }}</div>
  74. </template>
  75. <template slot="action" slot-scope="{text,record}">
  76. <rx-button class="clearBtn" alias="knowEdit" :butn-icon="'none'" @click="handleRemoveUserClick(record)">移除</rx-button>
  77. </template>
  78. </rx-grid> -->
  79. <a-table style="width:100%;"
  80. :columns="userColumns"
  81. :data-source="userList.slice((pageParam.pageNo-1)*pageParam.pageSize,pageParam.pageNo*pageParam.pageSize)"
  82. :heightauto="true"
  83. :scroll="{ x: 800}"
  84. :pagination="false">
  85. <template slot="groupSummary" slot-scope="text, record">
  86. <div style="white-space: pre-line">{{ text }}</div>
  87. </template>
  88. <template slot="action" slot-scope="text, record">
  89. <rx-button class="clearBtn" alias="knowEdit" :butn-icon="'none'" @click="handleRemoveUserClick(record)">移除</rx-button>
  90. </template>
  91. </a-table>
  92. <div style="width: 100%;display: flex;justify-content: flex-end;margin-top: 15px;">
  93. <a-pagination
  94. v-model="pageParam.pageNo"
  95. :page-size-options="['5']"
  96. :total="userList.length"
  97. show-size-changer
  98. showQuickJumper
  99. :page-size="pageParam.pageSize"
  100. @showSizeChange="handleShowSizeChange"
  101. @change="onChange"
  102. >
  103. <template slot="buildOptionText" slot-scope="props">
  104. <span>{{ props.value }}条/页</span>
  105. </template>
  106. </a-pagination>
  107. </div>
  108. </template>
  109. </template>
  110. </div>
  111. </template>
  112. </a-form-model>
  113. <a-form-model style="margin-top: 10px;">
  114. <a-row :gutter="24" type="flex">
  115. <a-col :span="12">
  116. <span class="titleBox">地图内容</span>
  117. </a-col>
  118. <a-col :span="12">
  119. <a-button v-if="tabRouteList.length < 10" type="primary" class="totBtn" @click.stop="addMapRoute">添加学习路径</a-button>
  120. </a-col>
  121. </a-row>
  122. <template v-if="tabRouteList.length">
  123. <a-tabs v-model="tabsKeys" size="large" :animated="false">
  124. <a-tab-pane v-for="(item,index) in tabRouteList" :key="index + 1 + ''">
  125. <span slot="tab">
  126. <div style="margin: 0 15px">
  127. <span style="margin:0 12px 0 0;">{{ item.name }}</span>
  128. <a-icon type="form" :style="{ color: '#000' }" @click.stop="handleEditTabClick(item,index)"/>
  129. <a-icon type="close" :style="{ color: '#000' }" style="margin-right:0;" @click.stop="handleDelTabClick(index)"/>
  130. </div>
  131. </span>
  132. <a-button type="dashed" style="width: 100%;color: #aaa;" @click.stop="addLearnInfo"><a-icon type="plus" style="margin-right: 8px;color: #aaa;" />新增学习内容</a-button>
  133. <pageList :contents="item.contents" @delItem="handleDelItemClick" @actionItem="handleActionItemClick" @setAddMapData="setAddMapData"></pageList>
  134. </a-tab-pane>
  135. </a-tabs>
  136. </template>
  137. <template v-else>
  138. <div class="empty-style">
  139. <a-empty />
  140. </div>
  141. </template>
  142. </a-form-model>
  143. </div>
  144. </div>
  145. </div>
  146. <!-- 员工数据 -->
  147. <a-modal v-model="showUserFlag"
  148. width="1000"
  149. title="添加员工"
  150. centered
  151. okText="保存"
  152. @ok="handleSaveUserOk">
  153. <org-people ref="orgPeopleRef" style="width:1000px;height:460px" :groupIds="groupIds" @transCheckedTarget="transCheckedTarget"></org-people>
  154. </a-modal>
  155. <!-- 学习路径 -->
  156. <a-modal v-model="showRouteFlag"
  157. width="500"
  158. :title="showRouteTitle"
  159. centered
  160. okText="保存"
  161. @ok="handleSaveRouteOk">
  162. <a-form-model style="margin-top: 10px;width:500px;">
  163. <a-form-model-item label="路径名称">
  164. <a-input v-model="routeForm.name" :maxLength="10" placeholder="请输入路径名称(10个汉字以内)"/>
  165. </a-form-model-item>
  166. <a-form-model-item label="路径排序">
  167. <a-input-number :disabled="showRouteTitle == '编辑学习路径'" v-model="routeForm.sort" :min="1" />
  168. </a-form-model-item>
  169. </a-form-model>
  170. </a-modal>
  171. <!-- 学习内容 -->
  172. <a-modal v-model="showLearnFlag"
  173. width="500"
  174. title="添加学习内容"
  175. centered
  176. okText="保存"
  177. :confirmLoading="saveLoading"
  178. @ok="handleSaveLearnOk">
  179. <a-form-model ref="learnRef" :model="learnForm" :rules="learnRules" style="width: 500px;" >
  180. <a-form-model-item label="内容类型" prop="type">
  181. <a-select v-model="learnForm.type" placeholder="请选择" @change="handleTypeChange">
  182. <a-select-option v-for="(item,index) in infoTypeList" :key="index" :value="item.value">
  183. {{item.label}}
  184. </a-select-option>
  185. </a-select>
  186. </a-form-model-item>
  187. <a-form-model-item label="系统名称" prop="outerSystemName" v-show="learnForm.type==1">
  188. <a-input v-model="learnForm.outerSystemName" :maxLength="20" placeholder="请输入" />
  189. </a-form-model-item>
  190. <a-form-model-item label="内容名称" prop="outerContentName" v-show="learnForm.type==1">
  191. <a-input v-model="learnForm.outerContentName" :maxLength="100" placeholder="请输入" />
  192. </a-form-model-item>
  193. <a-form-model-item label="访问地址" prop="outerAccessUrl" v-show="learnForm.type==1">
  194. <a-input v-model="learnForm.outerAccessUrl" placeholder="请输入一个网址" />
  195. </a-form-model-item>
  196. <a-form-model-item label="知识分类:" prop="classify" v-show="learnForm.type==2">
  197. <a-cascader v-model="learnForm.classify"
  198. class="scroll-ckunk"
  199. :popupStyle="{
  200. maxWidth: '40vw',
  201. 'overflow-x': 'auto',
  202. }"
  203. :getPopupContainer="triggerNode => { return triggerNode.parentNode }"
  204. :options="classifyList"
  205. :fieldNames="{ label: 'name', value: 'pkId', children: 'children' }"
  206. placeholder="请选择"
  207. changeOnSelect
  208. @change="handleClassifyChange" />
  209. </a-form-model-item>
  210. <a-form-model-item label="选择知识" prop="knowledgeId" v-show="learnForm.type==2">
  211. <a-select v-model="learnForm.knowledgeId" placeholder="请选择" :disabled="!learnForm.classify.length" @change="handleKnowledgeChange">
  212. <a-select-option v-for="(item,index) in knowledgeList" :key="index" :value="item.pkId">
  213. {{item.titles}}
  214. </a-select-option>
  215. </a-select>
  216. </a-form-model-item>
  217. </a-form-model>
  218. </a-modal>
  219. </div>
  220. </rx-layout>
  221. </template>
  222. <script>
  223. import breadcrumb from '../components/breadcrumb'
  224. import pageList from './components/pageList'
  225. import orgPeople from './components/orgPeople'
  226. import api from '@/api/knowledge/map/api'
  227. import configApi from '@/api/knowledge/config'
  228. import OsGroupApi from '@/api/user/org/osGroup'
  229. import classApi from '@/api/knowledge/classify'
  230. import initMixin from "../aMixin/initMixin"
  231. import getTimeNow from '@/views/modules/knowledge/aJs/getTimeNow'
  232. import SessionCache from '../aJs/cache'
  233. import { getParentNode } from '@/views/modules/knowledge/aJs/getClassifyTree'
  234. export default {
  235. name: 'knowledgeAddUpdate',
  236. mixins: [ initMixin ],
  237. components: {
  238. breadcrumb,
  239. pageList,
  240. orgPeople
  241. },
  242. data() {
  243. return {
  244. queryParam: {
  245. groupId: ''
  246. },
  247. api,
  248. classApi,
  249. extend: true,
  250. saveLoading: false,
  251. // 地图id
  252. pkId: '',
  253. mapForm: {
  254. type: undefined,
  255. name: '',
  256. groupId: [],
  257. groupSummary: "",
  258. groupPurview: undefined
  259. },
  260. groupIds: '',
  261. showParent: 'SHOW_PARENT',
  262. orgList: [],
  263. mapRules: {
  264. type: [
  265. { required: true, message: '请选择地图类型', trigger: 'blur' }
  266. ],
  267. name: [
  268. { required: true, message: '请输入地图标题', trigger: 'blur' }
  269. ],
  270. groupId: [
  271. { required: true, message: '请选择所属组织', trigger: 'change' }
  272. ],
  273. groupPurview: [
  274. { required: true, message: '请选择阅读权限', trigger: 'blur' }
  275. ],
  276. },
  277. showUserFlag: false,
  278. showUseNum: 0,
  279. pageParam: {
  280. pageNo: 1,
  281. pageSize: 5,
  282. },
  283. choosePeople: [],
  284. userList:[],
  285. userColumns: [
  286. {
  287. title: '员工ID',
  288. dataIndex: 'userId',
  289. align:'center',
  290. width: 120
  291. },
  292. {
  293. title: '工号',
  294. dataIndex: 'userNo',
  295. align:'center',
  296. width: 120
  297. },
  298. {
  299. title: '所属组织',
  300. dataIndex: 'groupSummary',
  301. align:'center',
  302. scopedSlots: {customRender: 'groupSummary'},
  303. width: 240
  304. },
  305. {
  306. title: '职位',
  307. dataIndex: 'positionGrade',
  308. align:'center',
  309. width: 180
  310. },
  311. {
  312. title: '员工姓名',
  313. dataIndex: 'fullName',
  314. align:'center',
  315. width: 120
  316. },
  317. {
  318. title: '添加时间',
  319. dataIndex: 'createTime',
  320. align:'center',
  321. width: 180
  322. },
  323. {
  324. title: '操作',
  325. dataIndex: 'action',
  326. align:'center',
  327. scopedSlots: { customRender: 'action' },
  328. width: 120
  329. },
  330. ],
  331. tabsKeys: '1',
  332. tabRouteList:[],
  333. showRouteTitle:'',
  334. chooseRouteIndex: 0,
  335. showRouteFlag: false,
  336. routeForm:{
  337. name:'',
  338. sort: 1
  339. },
  340. showLearnFlag:false,
  341. learnForm:{
  342. type: undefined,
  343. outerSystemName: '',
  344. outerContentName: '',
  345. outerAccessUrl: '',
  346. classify: [],
  347. knowledgeId: undefined
  348. },
  349. learnRules: {
  350. type: [
  351. { required: true, message: '请选择内容类型', trigger: 'blur' }
  352. ],
  353. },
  354. classifyList: [],
  355. knowledgeList: [],
  356. knowledgeInfo: {},
  357. authList: [
  358. {value: '1', label: '全部可见'},
  359. {value: '2', label: '部分员工可见'}
  360. ],
  361. mapTypeList: [],
  362. orgData: [],
  363. infoTypeList:[
  364. {value: '1', label: '外部系统'},
  365. {value: '2', label: '维基知识'}
  366. ],
  367. timeStamp: ''
  368. }
  369. },
  370. created() {
  371. let pkId = this.$route.query.pkId
  372. if(pkId) {
  373. this.pkId = pkId
  374. this.load(pkId);
  375. } else {
  376. this.load();
  377. }
  378. },
  379. methods: {
  380. load(pkId = false) {
  381. // 获取所属组织
  382. OsGroupApi.getAllOsGroupList({dimId:1}).then(res => {
  383. let listOption = []
  384. for (let i = 0; i < res.length; i++) {
  385. if(res[i].path && res[i].path.indexOf("C0000")>-1){
  386. let tempData = {}
  387. tempData.pId = res[i].parentId
  388. tempData.title = res[i].name
  389. tempData.id = res[i].key
  390. tempData.value = res[i].key
  391. tempData.label = res[i].deptPathName
  392. tempData.isLeaf = false
  393. let tempArr = res.filter(item => item.parentId == tempData.id)
  394. if(tempArr.length==0){
  395. tempData.isLeaf = true
  396. }
  397. listOption.push(tempData)
  398. }
  399. }
  400. this.orgData = listOption
  401. })
  402. // 获取地图字典
  403. api.dic({alias: 'KNOWLEDGE_MAP'}).then(res => {
  404. this.mapTypeList = res.data
  405. if(pkId) {
  406. this.timeStamp = this.$route.query.timeStamp
  407. if(SessionCache.getCache(this.timeStamp)) {
  408. let info = SessionCache.getCache(this.timeStamp)
  409. this.mapForm.type = info.type ? this.mapTypeList.find(item => item.value == info.type).value : undefined
  410. this.mapForm.name = info.name
  411. this.mapForm.groupId = info.groupId ? info.groupId.split(',') : []
  412. this.mapForm.groupSummary = info.groupSummary
  413. this.mapForm.groupPurview = info.groupPurview && info.groupPurview.toString()
  414. if(this.mapForm.groupPurview == 2) {
  415. this.userList = info.purviewUsers
  416. }
  417. this.tabRouteList = info.routes
  418. } else {
  419. api.info({pkId:pkId}).then(res => {
  420. let info = res.data
  421. this.mapForm.type = this.mapTypeList.find(item => item.name == info.typeName).value
  422. this.mapForm.name = info.name
  423. this.mapForm.groupId = info.groupId.split(',')
  424. this.mapForm.groupSummary = info.groupSummary
  425. this.mapForm.groupPurview = info.groupPurview.toString()
  426. if(info.routes && info.routes.length) {
  427. let disposeRoutes = info.routes
  428. disposeRoutes.forEach(item => {
  429. if(!item.contents) {
  430. item.contents = []
  431. }
  432. })
  433. this.tabRouteList = disposeRoutes
  434. } else {
  435. this.tabRouteList = []
  436. }
  437. if(this.mapForm.groupPurview == 2) {
  438. let queryParam = {
  439. pageNo: 1,
  440. pageSize: 9999,
  441. params: {
  442. pkId: pkId
  443. },
  444. sortField: '',
  445. sortOrder: 'asc'
  446. }
  447. api.purview(queryParam).then(res => {
  448. this.userList = res.result.data
  449. })
  450. }
  451. })
  452. }
  453. } else {
  454. if(this.$route.query.timeStamp) {
  455. this.timeStamp = this.$route.query.timeStamp
  456. if(SessionCache.getCache(this.timeStamp)) {
  457. let info = SessionCache.getCache(this.timeStamp)
  458. this.mapForm.type = info.type ? this.mapTypeList.find(item => item.value == info.type).value : undefined
  459. this.mapForm.name = info.name
  460. this.mapForm.groupId = info.groupId ? info.groupId.split(',') : []
  461. this.mapForm.groupSummary = info.groupSummary
  462. this.mapForm.groupPurview = info.groupPurview && info.groupPurview.toString()
  463. if(this.mapForm.groupPurview == 2) {
  464. this.userList = info.purviewUsers
  465. }
  466. this.tabRouteList = info.routes
  467. }
  468. }
  469. }
  470. })
  471. /*OsGroupApi.getAdminOrg().then(resp => {
  472. let data = resp.data;
  473. let temp = [];
  474. for (let i = 0; i < data.length; i++) {
  475. var rs = data[i];
  476. var _isLeaf = rs.childAmount == 0 ? true : false;
  477. temp.push({title: rs.name, id: rs.groupId, value: rs.key, isLeaf: _isLeaf})
  478. }
  479. this.orgData = [...temp];
  480. })*/
  481. this.init()
  482. },
  483. // 组织切换
  484. handleTreeChange(value) {
  485. this.mapForm.groupPurview = '1'
  486. this.userList = []
  487. },
  488. // 选中节点
  489. handleTreeSelect(value, node) {
  490. if(this.orgList.some(item => item.id == value)) return
  491. this.orgList.push({id:value, name: getParentNode(node).join('-')})
  492. },
  493. // 权限切换
  494. handleAuthChange(value) {
  495. this.userList = []
  496. },
  497. // 员工弹窗
  498. handleAddUserShow() {
  499. if(!this.mapForm.groupId.length) {
  500. this.$message.error('请先选择所属组织');
  501. return
  502. }
  503. this.showUserFlag = true
  504. this.groupIds = this.mapForm.groupId.join(',')
  505. if(this.showUseNum) {
  506. this.$refs.orgPeopleRef.queryParam.groupIds = this.groupIds
  507. this.$refs.orgPeopleRef.search()
  508. }
  509. this.showUseNum+=1
  510. },
  511. // 添加员工
  512. handleSaveUserOk() {
  513. // let res = this.$refs.orgPeopleRef.$refs.mapRef.getSelectedRows()
  514. // console.log(res)
  515. if(!this.choosePeople.length) {
  516. this.$message.error('请先选择员工');
  517. }
  518. this.choosePeople.forEach(item => {
  519. item.createTime = getTimeNow()
  520. })
  521. this.showUserFlag = false
  522. // if(this.pkId) {
  523. this.userList = [ ...this.userList, ...this.choosePeople ]
  524. const map = new Map()
  525. let filterList = this.userList.filter(el => !map.has(el.userId) && map.set(el.userId,true))
  526. this.userList = filterList
  527. this.$refs.orgPeopleRef.$refs.mapRef.selectedRowKeys = []
  528. this.choosePeople = []
  529. // } else {
  530. // this.userList = [ ...res ]
  531. // }
  532. },
  533. // 移除指定员工
  534. handleRemoveUserClick(record){
  535. let that = this
  536. this.$confirm({
  537. title: '确认要移除这个员工账号吗?',
  538. content: '删除后将无法恢复数据,请慎重选择',
  539. centered: true,
  540. icon: 'info-circle',
  541. okText:'确定',
  542. cancelText: '取消',
  543. onOk() {
  544. that.userList = that.userList.filter(item => item.userId != record.userId)
  545. console.log(that.userList.length/that.pageParam.pageSize)
  546. if((that.userList.length/that.pageParam.pageSize + 1) == that.pageParam.pageNo) {
  547. that.onChange(that.pageParam.pageNo - 1)
  548. }
  549. },
  550. });
  551. },
  552. // 添加路径
  553. addMapRoute(){
  554. this.showRouteTitle = '添加学习路径'
  555. this.routeForm = Object.assign({},this.$options.data().routeForm)
  556. if(this.tabRouteList.length) {
  557. if(this.tabRouteList.length == 1) {
  558. this.routeForm.sort = this.tabRouteList[0].sort + 1
  559. } else {
  560. let tabRouteinfo = JSON.parse(JSON.stringify(this.tabRouteList))
  561. let computedSort = tabRouteinfo.sort((a,b) => b.sort - a.sort)[0].sort
  562. this.routeForm.sort = computedSort + 1
  563. }
  564. }
  565. this.showRouteFlag = true
  566. },
  567. // 保存学习路径
  568. handleSaveRouteOk() {
  569. if(!this.routeForm.name) {
  570. this.$message.error('请输入路径名称')
  571. return
  572. }
  573. if(this.tabRouteList.some(item => item.name == this.routeForm.name)) {
  574. this.$message.error('路径名已存在')
  575. return
  576. }
  577. if(this.showRouteTitle == '编辑学习路径') {
  578. this.tabRouteList.splice(this.chooseRouteIndex,1,{
  579. ...this.routeForm,
  580. })
  581. } else {
  582. // 找到tabRouteList中大于等于routeForm.sort的索引
  583. let itemIndex = this.tabRouteList.findIndex(item => item.sort >= this.routeForm.sort)
  584. if(itemIndex == -1) {
  585. this.tabRouteList.push({
  586. ...this.routeForm,
  587. contents: []
  588. })
  589. } else {
  590. this.tabRouteList.splice(itemIndex,0,{
  591. ...this.routeForm,
  592. contents: []
  593. })
  594. }
  595. }
  596. // 直接push后排序
  597. // this.tabRouteList.push({
  598. // ...this.routeForm,
  599. // contents: []
  600. // })
  601. // this.tabRouteList = this.tabRouteList.sort((a,b)=>{ return a.sort-b.sort})
  602. this.showRouteFlag = false
  603. },
  604. // 编辑学习路径
  605. handleEditTabClick(item,index){
  606. this.chooseRouteIndex = index
  607. this.routeForm = JSON.parse(JSON.stringify(item))
  608. this.showRouteTitle = '编辑学习路径'
  609. this.showRouteFlag = true
  610. },
  611. // 删除学习路径
  612. handleDelTabClick(index){
  613. let that = this
  614. this.$confirm({
  615. title: '确认要删除这个学习路径吗?',
  616. content: '删除后将无法恢复数据,关联的学习内容也一并删除,请慎重选择',
  617. centered: true,
  618. icon: 'info-circle',
  619. okText:'确定',
  620. cancelText: '取消',
  621. onOk() {
  622. that.tabRouteList.splice(index,1)
  623. },
  624. });
  625. },
  626. // 学习内容类型选择
  627. handleTypeChange(value) {
  628. this.$refs.learnRef.clearValidate()
  629. this.learnRules = Object.assign({},this.$options.data().learnRules)
  630. let rules
  631. if(value == 1) {
  632. this.learnForm.classify = []
  633. this.learnForm.knowledgeId = undefined
  634. rules = {
  635. outerSystemName: [
  636. { required: true, message: '请输入系统名称', trigger: 'blur'}
  637. ],
  638. outerContentName: [
  639. { required: true, message: '请输入内容名称', trigger: 'blur'}
  640. ],
  641. outerAccessUrl: [
  642. { required: true, message: '请输入访问地址', trigger: 'blur'},
  643. { pattern: /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/, message: '访问地址格式不正确,请以https://或http://开头', trigger: 'blur'},
  644. ]
  645. }
  646. this.learnRules = {
  647. type: [
  648. { required: true, message: '请选择内容类型', trigger: 'blur' }
  649. ],
  650. ...rules
  651. }
  652. } else {
  653. this.learnForm.outerSystemName = ''
  654. this.learnForm.outerContentName = ''
  655. this.learnForm.outerAccessUrl = ''
  656. rules = {
  657. classify: [
  658. { required: true, message: '请选择分类', trigger: 'change'}
  659. ],
  660. knowledgeId: [
  661. { required: true, message: '请选择知识', trigger: 'change' }
  662. ]
  663. }
  664. this.learnRules = {
  665. type: [
  666. { required: true, message: '请选择分类', trigger: 'blur' }
  667. ],
  668. ...rules
  669. }
  670. }
  671. },
  672. // 添加学习内容
  673. addLearnInfo(){
  674. this.learnForm = Object.assign({},this.$options.data().learnForm)
  675. this.showLearnFlag = true
  676. setInterval(() => {
  677. document.querySelectorAll('.ant-cascader-menu-item').forEach(el => {
  678. el.onclick = function() {
  679. document.querySelector('.ant-cascader-menus').scrollLeft = 2048
  680. }
  681. })
  682. }, 1000)
  683. },
  684. // 选中分类
  685. async handleClassifyChange(value, selectedOptions) {
  686. if(value.length) {
  687. let res = await configApi.getfindAllWikiFromCategoryId(value.slice(-1)[0])
  688. this.knowledgeList = res.data
  689. }
  690. // 清空知识
  691. this.learnForm.knowledgeId = undefined
  692. },
  693. // 选中知识
  694. async handleKnowledgeChange(value) {
  695. let res = await api.knowledgeSnapshot({'pkId': value})
  696. this.knowledgeInfo = res.data
  697. },
  698. // 保存学习内容
  699. handleSaveLearnOk() {
  700. this.$refs.learnRef.validate(valid => {
  701. if(valid) {
  702. let tabs = this.tabRouteList[parseInt(this.tabsKeys)-1].contents
  703. if(this.learnForm.type == 1) {
  704. // 在相同系统下 内容要不同
  705. // if(tabs.some(item => item.outerSystemName == this.learnForm.outerSystemName) || tabs.some(item => item.outerContentName == this.learnForm.outerContentName)) {
  706. // this.$message.error('已添加相同的学习内容')
  707. // return
  708. // }
  709. // 外部系统
  710. let systemInfo = tabs.filter(item => item.outerSystemName == this.learnForm.outerSystemName)
  711. if(systemInfo.some(item => item.outerContentName == this.learnForm.outerContentName)) {
  712. this.$message.error('已添加相同的学习内容')
  713. return
  714. }
  715. this.saveLoading = true
  716. tabs.unshift({
  717. ...this.learnForm
  718. })
  719. } else {
  720. // 站内知识
  721. if(tabs.some(item => item.knowledgeId == this.learnForm.knowledgeId)) {
  722. this.$message.error('已添加相同的学习内容')
  723. return
  724. }
  725. this.saveLoading = true
  726. tabs.unshift({
  727. ...this.learnForm,
  728. ...this.knowledgeInfo
  729. })
  730. }
  731. this.showLearnFlag = false
  732. this.saveLoading = false
  733. }
  734. }
  735. )
  736. },
  737. // 移除学习内容
  738. handleDelItemClick(index) {
  739. this.tabRouteList[parseInt(this.tabsKeys)-1].contents.splice(index,1)
  740. },
  741. // 移动学习内容
  742. handleActionItemClick(info) {
  743. let data = JSON.parse(JSON.stringify(this.tabRouteList[parseInt(this.tabsKeys)-1].contents))
  744. this.tabRouteList[parseInt(this.tabsKeys)-1].contents = this.swapArray(data, info.index, info.action == 'up' ? (info.index - 1) : (info.index + 1))
  745. },
  746. // 元素互换位置
  747. swapArray(arr,index1,index2) {
  748. arr[index1]= arr.splice(index2, 1, arr[index1])[0];
  749. return arr
  750. },
  751. // 保存
  752. handleSaveClick() {
  753. this.$refs.mapRef.validate(valid => {
  754. if(valid) {
  755. if(this.mapForm.groupPurview == 2 && !this.userList.length) {
  756. this.$message.error('请选择员工')
  757. return
  758. }
  759. this.saveLoading = true
  760. let data = {
  761. ...this.mapForm,
  762. type: parseInt(this.mapForm.type),
  763. groupId: this.mapForm.groupId.join(','),
  764. groupSummary: this.orgList.length ?
  765. this.orgList.filter(item => this.mapForm.groupId.indexOf(item.id) > -1).map(item => { return item.name}).join("/")
  766. :
  767. this.mapForm.groupSummary,
  768. purviewUsers: this.userList.map(item => { return item.userId }),
  769. routes: this.tabRouteList
  770. }
  771. if(!this.pkId) {
  772. api.create(data).then(res => {
  773. if(res.code == 200) {
  774. this.$message.success('新增成功')
  775. setTimeout(() =>
  776. {
  777. this.$router.back()
  778. this.saveLoading = false
  779. }
  780. ,2000)
  781. }
  782. })
  783. } else {
  784. data['pkId'] = this.pkId
  785. api.edit(data).then(res => {
  786. if(res.code == 200) {
  787. this.$message.success('新增成功')
  788. setTimeout(() =>
  789. {
  790. this.$router.back()
  791. this.saveLoading = false
  792. }
  793. ,2000)
  794. }
  795. })
  796. }
  797. }
  798. })
  799. },
  800. // 存储到浏览器缓存
  801. setAddMapData() {
  802. if(!this.timeStamp) return
  803. let data = {
  804. ...this.mapForm,
  805. type: parseInt(this.mapForm.type),
  806. groupId: this.mapForm.groupId.join(','),
  807. groupSummary: this.orgList.length ?
  808. this.orgList.filter(item => this.mapForm.groupId.indexOf(item.id) > -1).map(item => { return item.name}).join("/")
  809. :
  810. this.mapForm.groupSummary,
  811. purviewUsers: this.userList,
  812. routes: this.tabRouteList
  813. }
  814. SessionCache.setCache(this.timeStamp,data)
  815. },
  816. transCheckedTarget(arg) {
  817. this.choosePeople = arg
  818. },
  819. // 每页条数
  820. handleShowSizeChange(current, pageSize) {
  821. this.pageParam.pageNo = current
  822. this.pageParam.pageSize = pageSize;
  823. },
  824. // 跳转
  825. onChange(pageNumber) {
  826. this.pageParam.pageNo = pageNumber
  827. },
  828. //加载左树下的子节点
  829. onLoadGroupTree(treeNode) {
  830. if (treeNode.dataRef.children) {
  831. return;
  832. }
  833. return OsGroupApi.getParentGroup(treeNode.dataRef.id).then(data => {
  834. let treeData = []
  835. for (let i = 0; i < data.length; i++) {
  836. var rs = data[i]
  837. var _isLeaf = rs.childAmount == 0 ? true : false;
  838. treeData.push({title: rs.name, id: rs.groupId, value: rs.key,isLeaf: _isLeaf})
  839. }
  840. var orgData = this.getGroupTree(this.orgData, treeNode.dataRef.id, treeData);
  841. this.orgData = [...orgData];
  842. })
  843. },
  844. getGroupTree(orgData, id, treeData) {
  845. if (treeData.length > 0) {
  846. for (var i = 0; i < orgData.length; i++) {
  847. if (orgData[i].id == id) {
  848. orgData[i].children = treeData;
  849. break;
  850. }
  851. if (orgData[i].children) {
  852. this.getGroupTree(orgData[i].children, id, treeData);
  853. }
  854. }
  855. }
  856. return orgData;
  857. }
  858. }
  859. }
  860. </script>
  861. <style lang="less" scoped>
  862. @gary: #f8f8f8;
  863. @white: #fff;
  864. @fontSize: 17px;
  865. .mainContent {
  866. min-height: 100%;
  867. width: 100%;
  868. padding: 40px;
  869. background: #f8f8f8;
  870. position: relative;
  871. .ant-breadcrumb {
  872. position:absolute;
  873. top:10px;
  874. }
  875. .body {
  876. height: 100%;
  877. background: #f8f8f8;
  878. .content {
  879. height: 100%;
  880. background: #f8f8f8;
  881. form{
  882. background: @white;
  883. padding: 20px 40px;
  884. }
  885. .ant-form-item {
  886. width: 50%;
  887. margin: 8px 0 12px;
  888. }
  889. .empty-style {
  890. height:300px;
  891. display:flex;
  892. align-items:center;
  893. justify-content:center;
  894. }
  895. }
  896. }
  897. }
  898. .accessory-show {
  899. display:flex;
  900. align-items: center;
  901. img {
  902. width: 32px;
  903. height: 32px;
  904. }
  905. span {
  906. margin: 0 40px 0 10px;
  907. }
  908. }
  909. .clearBtn {
  910. background: none;
  911. color: #3294F7;
  912. text-shadow: none;
  913. padding: 0px 6px;
  914. border: none;
  915. box-shadow: none;
  916. }
  917. .titleBox{
  918. color: #000;
  919. font-size: @fontSize;
  920. }
  921. </style>
  922. <style scoped>
  923. /deep/ .ant-upload.ant-upload-drag {
  924. width: 30%;
  925. background: #fff;
  926. }
  927. /deep/.ant-btn > .anticon + span {
  928. margin-left: 0;
  929. }
  930. /deep/ .ant-tabs-bar {
  931. padding-left: 0;
  932. }
  933. /deep/ .ant-tabs .ant-tabs-large-bar .ant-tabs-tab {
  934. margin: 0 10px!important;
  935. padding: 23px 0;
  936. }
  937. /deep/ .ant-tabs-ink-bar {
  938. bottom: 2px;
  939. height: 1.5px;
  940. }
  941. /deep/ .ant-tabs-nav-container {
  942. font-size: 14px!important;
  943. }
  944. .totBtn{
  945. float: right;
  946. }
  947. /* /deep/ .ant-modal-body {
  948. padding: 0;
  949. } */
  950. /deep/ .ant-modal-footer {
  951. padding-right: 24px;
  952. }
  953. /* /deep/ .ant-select-selection__choice__remove {
  954. font-size: 0px!important;
  955. } */
  956. /* /deep/ .ant-select-selection__choice {
  957. padding: 0 10px;
  958. } */
  959. /* /deep/ .rx-gridBox {
  960. margin-left: 12px;
  961. } */
  962. /deep/.gridContent {
  963. border: none!important;;
  964. }
  965. /deep/.ant-table-thead > tr > th {
  966. text-align: center;
  967. height: 54px;
  968. }
  969. /deep/ .ant-table-tbody > tr > td {
  970. height: 54px;
  971. }
  972. /deep/ .ant-btn-dashed:hover, .ant-btn-dashed:focus {
  973. color: #aaa;
  974. background-color: #fff;
  975. border-color: #ccc;
  976. }
  977. /deep/ .ant-cascader-menus {
  978. left: 0!important;
  979. }
  980. /deep/ .ant-cascader-menu:last-child {
  981. margin-right: 0;
  982. }
  983. /deep/ .ant-modal-wrap {
  984. overflow: inherit;
  985. }
  986. </style>