addUpdateMap.vue 29 KB

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