addUpdateMap.vue 27 KB

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