useCasePage.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. <template>
  2. <div id="init-window" style="position:relative; min-height:95vh; background:#F2F3F6;">
  3. <router-view />
  4. <div style="position: absolute;width: 100%;">
  5. <div style="background:#F2F3F6;">
  6. <el-container>
  7. <el-aside width="17%" style=" background: #FFF;margin: 1% 0 1% 1%; border-radius:8px;">
  8. <div class="nav_Input" style="min-height:90vh;">
  9. <br>
  10. <p v-show="node_Data" style="cursor: pointer; margin: 100% 0;font-size:14px; text-align:center;" @click="createFolder">新建文件夹</p>
  11. <el-tree
  12. v-if="dataShow"
  13. style="overflow-x:auto; min-width:100%;display:inline-block !important"
  14. :data="data1"
  15. node-key="id"
  16. draggable
  17. :default-expanded-keys="key_arr"
  18. :expand-on-click-node="false"
  19. @node-drag-start="handleDragStart"
  20. @node-drag-enter="handleDragEnter"
  21. @node-drag-leave="handleDragLeave"
  22. @node-drag-over="handleDragOver"
  23. @node-drag-end="handleDragEnd"
  24. @node-drop="handleDrop"
  25. @node-click="clickFun"
  26. >
  27. <span slot-scope="{ node, data }" style="width:100%;" class="custom-tree-node" @mouseenter="mouseenter(data)" @mouseleave="mouseleave(data)">
  28. <span :title="data.label" class="span_el" @dblclick="dblclick(data)">{{ node.label }}</span>
  29. <el-input v-if="data.que" ref="get_Input" v-model="node_Name.name" size="mini" @blur="queryNodeName(node_Name.name, data)">输入框</el-input>
  30. <el-dropdown v-show="data.del" style="margin-left:10px" trigger="click">
  31. <span class="el-dropdown-link">
  32. ···<i class="el-icon--right" />
  33. </span>
  34. <el-dropdown-menu slot="dropdown">
  35. <el-dropdown-item @click.native="createFolder">新建节点</el-dropdown-item>
  36. <el-dropdown-item @click.native="dblclick(data)">编辑节点</el-dropdown-item>
  37. <el-dropdown-item @click.native="() => remove(node, data)">删除节点</el-dropdown-item>
  38. <el-dropdown-item @click.native="() => append(data)">新建子节点</el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. </span>
  42. </el-tree>
  43. <el-input v-if="Folder_Show" ref="input1" v-model="add_Folder" size="mini" placeholder="新建文件夹" @blur="hide_input(add_Folder)" />
  44. </div>
  45. </el-aside>
  46. <el-container>
  47. <el-header style="background:#ffffff;height:auto; width:98%;margin: 1%; font-size:13px; border-radius:8px;">
  48. <el-row>
  49. <el-col style="white-space:nowrap; display: flex; justify-content: center; align-items: center;margin-top:1.3%;">
  50. 用例名称
  51. <el-input v-model="createParticipation.title" clearable placeholder="请输入内容" style="margin-left:0.5%;" />
  52. <el-button style="margin-left:1%;" type="primary" @click="queryCaseData(createParticipation)">查询</el-button>
  53. <el-button @click="queryUpdateCreatd('', 3)">新增</el-button>
  54. </el-col>
  55. </el-row>
  56. <el-row>
  57. <el-col style="white-space:nowrap; display: flex; justify-content: center; align-items: center;margin:1.3% 0;">
  58. <div style="flex:1;display: flex;justify-content: center; align-items: center">
  59. 序列号 &nbsp;<el-input v-model="createParticipation.id" placeholder="用例名" clearable style="width: 42%;margin: 0 2% 0 2%;" class="filter-item" />
  60. 优先级
  61. <el-select v-model="createParticipation.casePriority" style="width: 40%;margin: 0 4% 0 3%;" clearable placeholder="优先级">
  62. <el-option v-for="item in priorityStrings" :key="item.value" :label="item.name" :value="item.value" />
  63. </el-select>
  64. </div>
  65. <div style="flex:1;display: flex;justify-content: center; align-items: center">
  66. 操作人 &nbsp;<el-input v-model="createParticipation.modifier" placeholder="操作人" clearable style="width: 100%;margin-left:1.7%;" class="filter-item" />
  67. </div>
  68. </el-col>
  69. </el-row>
  70. <el-row>
  71. <el-col style="white-space:nowrap; display: flex; justify-content: center; align-items: center;margin-bottom:1%;">
  72. <div style="flex:1;display: flex;justify-content: center; align-items: center">
  73. 创建时间
  74. <el-date-picker v-model="createParticipation.createTime" style="width:40%;margin: 0 3% 0 1%;" type="datetime" placeholder="开始日期" /><span style="margin: 0 1.1% 0 1.1% ;"> 一 </span>
  75. <el-date-picker v-model="createParticipation.modifyTime" style="width:40%;margin: 0 4% 0 3%;" type="datetime" placeholder="结束日期" />
  76. </div>
  77. <div style="flex:1;display: flex;justify-content: center; align-items: center">
  78. 项目名称 <el-input v-model="createParticipation.projectName" placeholder="创建人" clearable style="width: 50%;margin: 0 2% 0 1%;" class="filter-item" />
  79. 需求名称<el-input v-model="createParticipation.taskName" placeholder="创建人" clearable style="width: 50%;margin-left:2%;" class="filter-item" />
  80. </div>
  81. <input id="imFile" ref="imFile" type="file" style="display: none" @change="importFile(this)">
  82. </el-col>
  83. </el-row>
  84. </el-header>
  85. <el-main style="background:#ffffff; width:98%;margin:0% 1% 1% 1%; font-size:14px;border-radius:8px;">
  86. <el-button type="primary" style="margin-left:1%;" @click="uploadFile()">导入</el-button>
  87. <el-tooltip class="item" effect="light" content="导出勾选项,没有勾选将导出excel模版" placement="top">
  88. <el-button style="margin-left:2%;" @click="exportExcel">导出</el-button>
  89. </el-tooltip>
  90. <!-- 主页table -->
  91. <el-table :data="gridData" size="mini" :header-cell-style="{ background: '#F0F2F4', color: '#333B4A' }" style="width: 100%; font-size:13px;margin-top:1%;" border @select-all="clickAllData" @selection-change="handleSelectionChange">
  92. <el-table-column type="selection" min-width="50" align="center" @change="clickAllData(gridData)" />
  93. <el-table-column prop="id" label="序列号" min-width="80" align="center">
  94. <template slot-scope="scope">{{ scope.row.id }}</template>
  95. </el-table-column>
  96. <el-table-column prop="caseCondition" :show-overflow-tooltip="true" label="用例名称" min-width="240" align="center">
  97. <template slot-scope="scope"><span style="color:#409EFF; cursor: pointer" @click="queryUpdateCreatd(scope.row, 1)">{{ scope.row.title }}</span></template>
  98. </el-table-column>
  99. <el-table-column prop="casePriority" label="优先级" min-width="80" align="center">
  100. <template slot-scope="scope">{{ scope.row.casePriorityName }}</template>
  101. </el-table-column>
  102. <el-table-column prop="creatorName" label="操作人" min-width="110" align="center">
  103. <template slot-scope="scope">{{ scope.row.modifier }}</template>
  104. </el-table-column>
  105. <el-table-column label="操作" min-width="150px" align="center">
  106. <template slot-scope="scope">
  107. <el-button size="mini" type="primary" plain @click="queryUpdateCreatd(scope.row, 2)">编辑</el-button>
  108. <el-button size="mini" type="danger" plain @click="deleteCaseData(scope.row.id)">删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <!-- 导出文件内容 -->
  113. <el-table v-show="false" id="out-table" :data="tableData" tooltip-effect="dark" style="width: 100%">
  114. <el-table-column prop="id" label="序号" width="50" />
  115. <el-table-column prop="description" label="测试步骤" />
  116. <el-table-column prop="expectedResult" label="期望结果" />
  117. <el-table-column prop="casePriority" label="优先级" />
  118. <el-table-column prop="caseCondition" label="前置条件" />
  119. <el-table-column prop="api" label="api" />
  120. <el-table-column prop="accessory" label="附件" />
  121. <el-table-column prop="remark" label="备注" />
  122. </el-table>
  123. <div align="center" class="block">
  124. <el-pagination :current-page="curIndex" background :page-sizes="[5]" :page-size="pageSize" layout="total, prev, pager, next" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  125. </div>
  126. </el-main>
  127. </el-container>
  128. </el-container>
  129. </div>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import { createFolderData, queryAllFolderData, queryCasesData, deleteFolderData, deleteCaseData, updateFolderData, caseUpdateFolderName } from '@/api/caseProject.js'
  135. import { mockUrl } from '@/apiConfig/api'
  136. // import FileSaver from 'file-saver'
  137. import axios from 'axios'
  138. // import XLSX from 'xlsx'
  139. // import Utils from '../../util.js'
  140. export default {
  141. name: 'UseCasePage',
  142. data() {
  143. return {
  144. key_arr: [],
  145. fileList: [],
  146. id: '',
  147. label: '',
  148. node_Name: {},
  149. Folder_Show: false,
  150. add_Folder: '',
  151. node_Data: false,
  152. dataShow: true,
  153. priorityStrings: [{ name: 'p0', value: 0 }, { name: 'p1', value: 1 }, { name: 'p2', value: 2 }, { name: 'p3', value: 3 }],
  154. userInformation: localStorage.getItem('username'),
  155. userNames: localStorage.getItem('realname'),
  156. bizJson: localStorage.getItem('key'),
  157. userData: '',
  158. caseInfo: '',
  159. pageSize: 5,
  160. curIndex: 1,
  161. startId: '',
  162. end: '',
  163. total: 0,
  164. createParticipation: {},
  165. moduleTypeStr: [],
  166. gridData: [],
  167. formData: {},
  168. data1: [],
  169. tableData: [],
  170. imFile: '',
  171. failNum: '',
  172. o_number: '',
  173. successNum: '',
  174. startKey: '',
  175. obj: '',
  176. end_Data: '',
  177. return_URL: ''
  178. }
  179. },
  180. created() {
  181. this.AllQueryFolderData(localStorage.getItem('key'))
  182. },
  183. mounted() {
  184. // var that = this
  185. // Utils.$on('demo', function(msg) {
  186. // that.AllQueryFolderData(msg)
  187. // })
  188. this.imFile = document.getElementById('imFile')
  189. this.initWindow()
  190. // this.AllQueryFolderData(localStorage.getItem('key'))
  191. },
  192. methods: {
  193. // 左侧导航栏
  194. AllQueryFolderData(e) {
  195. if (e !== '') {
  196. this.gridData = []
  197. this.data1 = []
  198. this.formData = { bizId: e }
  199. queryAllFolderData(this.formData).then(res => {
  200. if (res.code === 200) {
  201. for (var ele of res.data) {
  202. var arr = {}
  203. arr.id = ele.id
  204. arr.label = ele.folderName
  205. arr.children = []
  206. if (ele.subCaseFolderInfos !== null) {
  207. for (var vel of ele.subCaseFolderInfos) {
  208. var add = {}
  209. add.id = vel.id
  210. add.label = vel.folderName
  211. add.children = []
  212. if (vel.subCaseFolderInfos !== null) {
  213. for (var v of vel.subCaseFolderInfos) {
  214. var as = {}
  215. as.id = v.id
  216. as.label = v.folderName
  217. as.children = []
  218. if (v.subCaseFolderInfos != null) {
  219. for (var a of v.subCaseFolderInfos) {
  220. var add4 = {}
  221. add4.id = a.id
  222. add4.label = a.folderName
  223. as.children.push(add4)
  224. }
  225. }
  226. add.children.push(as)
  227. }
  228. }
  229. arr.children.push(add)
  230. }
  231. }
  232. this.data1.push(arr)
  233. }
  234. if (this.data1.length === 0) {
  235. this.node_Data = true
  236. this.dataShow = false
  237. } else {
  238. this.node_Data = false
  239. this.dataShow = true
  240. }
  241. } else {
  242. this.dataShow = false
  243. this.node_Data = true
  244. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  245. }
  246. })
  247. } else {
  248. this.dataShow = false
  249. this.node_Data = true
  250. this.$message({ message: '请先选择业务线', type: 'error', duration: 1000, offset: 150 })
  251. }
  252. },
  253. // 双击编辑
  254. dblclick(data) {
  255. this.label = data.label// 当前选中的名称
  256. this.id = data.id // 当前选中id
  257. this.$set(data, 'label', '')
  258. this.$set(data, 'que', true)
  259. this.$set(data, 'del', false)
  260. this.$set(this.node_Name, 'name', this.label)
  261. setTimeout(() => { this.$refs.get_Input.focus() }, 100)
  262. this.$nextTick(() => {
  263. this.$refs.get_Input.focus()
  264. })
  265. },
  266. // 添加节点
  267. append(data) {
  268. this.formData = {
  269. bizId: this.bizJson,
  270. folderName: '新建子节点',
  271. xmindUrl: '',
  272. parentFolderId: this.startId,
  273. creator: this.userInformation,
  274. modifier: this.userInformation
  275. }
  276. createFolderData(this.formData).then(res => {
  277. console.log(res.data)
  278. if (res.code === 200) {
  279. const newChild = { id: res.data, label: '新建子节点', children: [] }
  280. if (!data.children) {
  281. this.$set(data, 'children', [])
  282. }
  283. data.children.push(newChild)
  284. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  285. this.data1 = []
  286. this.AllQueryFolderData(this.bizJson)
  287. this.key_arr.push(this.startId)
  288. this.add_Folder = ''
  289. } else {
  290. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  291. this.add_Folder = ''
  292. }
  293. })
  294. },
  295. // 更新节点
  296. queryNodeName(val, data) {
  297. if (val === '') { // 判断用户是否有输入
  298. val = this.label // 没有输入拿之前的label替代
  299. this.end_Data = { folderName: val, xmindUrl: '', id: data.id, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation }
  300. } else {
  301. this.end_Data = { folderName: val, xmindUrl: '', id: data.id, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation }
  302. }
  303. this.$set(data, 'que', false) // 失去焦点隐藏input
  304. this.$set(this.node_Name, 'name', '') // 清空input
  305. caseUpdateFolderName(this.end_Data).then(res => {
  306. if (res.code === 200) {
  307. this.$message({ type: 'success', message: res.msg, duration: 1000 })
  308. this.data1 = []
  309. this.AllQueryFolderData(localStorage.getItem('key'))
  310. } else {
  311. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  312. this.data1 = []
  313. this.AllQueryFolderData(localStorage.getItem('key'))
  314. }
  315. })
  316. },
  317. // 显示隐藏删除图标
  318. mouseenter(data) {
  319. this.$set(data, 'del', true)
  320. },
  321. mouseleave(data) {
  322. this.$set(data, 'del', false)
  323. },
  324. // 隐藏主页样式
  325. initWindow() {
  326. if (!document.getElementById('window-judge')) {
  327. document.getElementById('init-window').parentNode.style.overflow = 'auto'
  328. } else {
  329. document.getElementById('init-window').parentNode.style.overflow = 'hidden'
  330. }
  331. },
  332. // 分页信息
  333. handleSizeChange(size) {
  334. this.pageSize = size
  335. this.pageIndex()
  336. },
  337. handleCurrentChange(curIndex) {
  338. this.curIndex = curIndex
  339. this.pageIndex()
  340. },
  341. pageIndex() {
  342. queryCasesData({ caseFolderId: this.startId, curIndex: this.curIndex, pageSize: this.pageSize }).then(res => {
  343. this.gridData = res.data.list
  344. })
  345. },
  346. // table全选调用查询接口
  347. clickAllData(rows) {
  348. queryCasesData({ caseFolderId: this.startId }).then(res => {
  349. this.tableData = res.data.list
  350. })
  351. },
  352. // 新建文件夹
  353. createFolder() {
  354. this.Folder_Show = true
  355. this.add_Folder = ''
  356. this.node_Data = false
  357. setTimeout(() => { this.$refs.input1.focus() }, 100)
  358. },
  359. // input失去焦点新增(或取消)
  360. hide_input(vel) {
  361. if (vel !== '') {
  362. this.formData = {
  363. bizId: this.bizJson,
  364. folderName: vel,
  365. xmindUrl: '',
  366. parentFolderId: '-1',
  367. creator: this.userInformation,
  368. modifier: this.userInformation
  369. }
  370. createFolderData(this.formData).then(res => {
  371. if (res.code === 200) {
  372. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  373. this.dataShow = true
  374. this.node_Data = false
  375. this.data1 = []
  376. this.AllQueryFolderData(this.bizJson)
  377. } else {
  378. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  379. }
  380. })
  381. this.Folder_Show = false
  382. } else {
  383. if (this.data1 === '') {
  384. this.node_Data = true
  385. } else {
  386. this.Folder_Show = false
  387. this.node_Data = false
  388. }
  389. this.$message({ message: '取消创建文件夹', type: 'success', duration: 1000, offset: 150 })
  390. }
  391. },
  392. // 查询
  393. queryCaseData(ele) {
  394. if (this.createParticipation.caseName === '') return false
  395. if (this.startId === '') {
  396. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  397. } else {
  398. this.createParticipation = ele
  399. this.createParticipation.caseFolderId = this.startId
  400. this.createParticipation.pageSize = this.pageSize
  401. this.createParticipation.curIndex = this.curIndex
  402. queryCasesData(this.createParticipation).then(res => {
  403. this.gridData = res.data.list
  404. })
  405. }
  406. },
  407. queryUpdateCreatd(ele, e) {
  408. if (this.startId === '') {
  409. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  410. } else {
  411. switch (e) {
  412. case 1: // 查看
  413. this.$router.push({ path: '/Platform/useCasePage/queryUse', query: { id: ele.id, caseFolderId: ele.caseFolderId }})
  414. break
  415. case 2: // 编辑
  416. this.$router.push({ path: '/Platform/useCasePage/createUse', query: { id: ele.id, caseFolderId: ele.caseFolderId }})
  417. break
  418. case 3: // 新增
  419. this.$router.push({ path: '/Platform/useCasePage/createUse', query: { data: this.startId }})
  420. break
  421. }
  422. }
  423. },
  424. handleSelectionChange(val) {
  425. this.tableData = []
  426. for (var e of val) {
  427. this.tableData.push(e.id)
  428. }
  429. },
  430. // nav
  431. handleDragStart(node, ev) {
  432. console.log('节点开始拖拽时触发的事件', node.key)
  433. this.startKey = node.key
  434. },
  435. handleDragEnter(draggingNode, dropNode, ev) {
  436. console.log('拖拽进入其他节点时触发的事件', dropNode.data.id)
  437. },
  438. handleDragLeave(draggingNode, dropNode, ev) {
  439. console.log('拖拽离开某个节点时触发的事件', dropNode.data.id)
  440. },
  441. handleDragOver(draggingNode, dropNode, ev) {
  442. console.log('在拖拽节点时触发的事件', dropNode.data.id)
  443. },
  444. handleDragEnd(draggingNode, dropNode, dropType, ev) {
  445. console.log('拖拽结束时(可能未成功)触发的事件', dropNode && dropNode.key, dropType)
  446. },
  447. handleDrop(draggingNode, dropNode, dropType, ev) {
  448. console.log('拖拽成功完成时触发的事件', dropNode.key, dropType)
  449. var startEnd = { parentFolderId: dropNode.key, id: this.startKey, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation, xmindUrl: '' }
  450. this.ConfirmSubmission(startEnd)
  451. },
  452. ConfirmSubmission(vel) {
  453. updateFolderData(vel).then(res => {
  454. if (res.code === 200) {
  455. this.$message({ type: 'success', message: res.msg, duration: 1000 })
  456. this.data1 = []
  457. this.AllQueryFolderData(localStorage.getItem('key'))
  458. } else {
  459. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  460. this.data1 = []
  461. this.AllQueryFolderData(localStorage.getItem('key'))
  462. }
  463. })
  464. },
  465. // 删除
  466. remove(node, data) {
  467. this.$confirm('是否确认删除', '确认信息', {
  468. distinguishCancelAndClose: true,
  469. confirmButtonText: '确定',
  470. cancelButtonText: '取消'
  471. })
  472. .then(() => {
  473. this.formData = {
  474. id: node.data.id,
  475. modifier: node.data.id
  476. }
  477. deleteFolderData(this.formData).then(res => {
  478. if (res.code === 200) {
  479. this.$message({ type: 'success', message: '已删除' })
  480. this.data1 = []
  481. this.AllQueryFolderData(localStorage.getItem('key'))
  482. } else {
  483. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  484. }
  485. })
  486. })
  487. .catch(action => {
  488. this.$message({ type: 'success', message: '已取消' })
  489. })
  490. },
  491. // 点击节点
  492. clickFun(e) {
  493. console.log(e)
  494. if (this.startId !== e.id) {
  495. this.key_arr = []
  496. }
  497. this.startId = e.id
  498. queryCasesData({ pageSize: 5, curIndex: 1, caseFolderId: e.id }).then(res => {
  499. this.gridData = res.data.list
  500. this.total = res.data.total
  501. })
  502. },
  503. // 表格信息删除
  504. deleteCaseData(e) {
  505. if (this.startId === '') {
  506. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  507. } else {
  508. this.$confirm('是否确认删除', '确认信息', {
  509. distinguishCancelAndClose: true,
  510. confirmButtonText: '确定',
  511. cancelButtonText: '取消'
  512. })
  513. .then(() => {
  514. this.caseInfo = { id: e, modifier: this.userInformation }
  515. deleteCaseData(this.caseInfo).then(res => {
  516. if (res.code === 200) {
  517. var data = {
  518. pageSize: this.pageSize,
  519. curIndex: this.curIndex,
  520. caseFolderId: this.startId
  521. }
  522. queryCasesData(data).then(res => {
  523. this.gridData = res.data.list
  524. this.$message({ type: 'success', message: '已删除' })
  525. })
  526. } else {
  527. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  528. }
  529. })
  530. })
  531. .catch(action => { this.$message({ type: 'success', message: '已取消' }) })
  532. }
  533. },
  534. // 导出
  535. exportExcel() {
  536. var case_from = {
  537. accessory: '/Users/didi/Desktop',
  538. caseFolderId: this.startId,
  539. caseIds: this.tableData
  540. }
  541. axios({
  542. method: 'post',
  543. url: 'http://10.179.24.176:8980/case/downloadCase', // 请求地址
  544. data: case_from, // 参数
  545. responseType: 'blob' // 表明返回服务器返回的数据类型
  546. })
  547. .then((res) => {
  548. const content = res
  549. const blob = new Blob([content])
  550. if ('download' in document.createElement('a')) { // 非IE下载
  551. const elink = document.createElement('a')
  552. elink.download = '导出信息.xls'
  553. elink.style.display = 'none'
  554. elink.href = URL.createObjectURL(blob)
  555. document.body.appendChild(elink)
  556. elink.click()
  557. URL.revokeObjectURL(elink.href) // 释放URL 对象
  558. document.body.removeChild(elink)
  559. }
  560. })
  561. // if (this.startId === '') {
  562. // this.$message({ message: '提示,👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  563. // } else {
  564. // var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
  565. // var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
  566. // try {
  567. // FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
  568. // } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  569. // return wbout
  570. // }
  571. },
  572. downLoadXls(data, filename) {
  573. // var blob = new Blob([data], {type: 'application/vnd.ms-excel'})接收的是blob,若接收的是文件流,需要转化一下
  574. if (typeof window.chrome !== 'undefined') {
  575. // Chrome version
  576. var link = document.createElement('a')
  577. link.href = window.URL.createObjectURL(data)
  578. link.download = filename
  579. link.click()
  580. } else if (typeof window.navigator.msSaveBlob !== 'undefined') {
  581. // IE version
  582. var blob = new Blob([data], { type: 'application/force-download' })
  583. window.navigator.msSaveBlob(blob, filename)
  584. } else {
  585. // Firefox version
  586. var file = new File([data], filename, { type: 'application/force-download' })
  587. window.open(URL.createObjectURL(file))
  588. }
  589. },
  590. // 导入excel
  591. importFile() {
  592. var obj = this.imFile
  593. if (!obj.files) { return }
  594. var f = obj.files[0]
  595. console.log(f)
  596. var a_name = f.name.split('.')
  597. console.log(a_name[1])
  598. if (a_name[1] === 'xlsx') {
  599. var formData = new FormData()
  600. formData.append('file', f)
  601. var caseInfo = {
  602. bizId: this.bizJson,
  603. creator: this.userNames,
  604. modifier: this.userNames,
  605. caseFolderId: this.startId
  606. }
  607. formData.append('caseInfo', JSON.stringify(caseInfo))
  608. axios.post(mockUrl + '/case/uploadCase', formData, { headers: { 'Content-Type': 'multipart/form-data' }}).then(res => {
  609. var code = res.data.data
  610. this.successNum = code.successNum
  611. this.failNum = code.failNum
  612. if (res.data.code === 200) {
  613. if (this.failNum === 0) {
  614. this.updateCaseListData()
  615. } else {
  616. this.haha = '上传成功' + this.successNum + '上传失败' + this.failNum
  617. this.$notify({ title: 'error', message: this.haha, type: 'success', duration: 2000 })
  618. }
  619. this.$refs.imFile.value = null
  620. } else {
  621. this.$message({ type: 'success', message: '导入失败' })
  622. }
  623. })
  624. }
  625. if (a_name[1] === 'xmind') {
  626. var formData_s = new FormData()
  627. formData_s.append('file', f)
  628. axios.post('http://star.xiaojukeji.com/upload/img.node', formData_s, { headers: { 'Content-Type': 'application/json; charset=UTF-8' }}).then(res => {
  629. console.error(res)
  630. })
  631. }
  632. // if (a_name[1] !== 'ximnd') {
  633. // if (a_name[1] !== 'xlsx') {
  634. // this.$message({ type: 'error', message: '导入失败,不支持文件类型' })
  635. // }
  636. // }
  637. },
  638. // 按钮导入
  639. uploadFile() {
  640. if (this.startId === '') {
  641. this.$message({ message: '提示,👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  642. } else {
  643. this.$refs.imFile.click()
  644. }
  645. },
  646. updateCaseListData() {
  647. this.createParticipation.caseFolderId = this.startId
  648. this.createParticipation.pageSize = this.pageSize
  649. this.createParticipation.curIndex = this.curIndex
  650. queryCasesData(this.createParticipation).then(res => {
  651. this.gridData = res.data.list
  652. this.$message({ type: res.msg, message: res.msg, duration: 1000 })
  653. })
  654. }
  655. }
  656. }
  657. </script>
  658. <style>
  659. .custom-tree-node {
  660. flex: 1;
  661. display: flex;
  662. align-items: center;
  663. justify-content: space-between;
  664. font-size: 14px;
  665. padding-right: 8px;
  666. }
  667. .nav_Input .el-input--mini .el-input__inner {
  668. height: 23px !important;
  669. }
  670. .span_el {
  671. display: block;
  672. overflow: hidden;
  673. text-overflow: ellipsis;
  674. }
  675. .btn_query .el-button--primary.is-plain {
  676. color: #000000 !important;
  677. background: #F9F9FA !important;
  678. border-color: #F9F9FA !important;
  679. }
  680. .nav_Input .el-tree-node__children .custom-tree-node{
  681. color: #6F7C93;
  682. }
  683. .nav_Input .el-tree-node__content {
  684. color: #333B4A;
  685. }
  686. .nav_Input .el-tree-node__content .el-tree-node__expand-icon{
  687. color: #333B4A;
  688. }
  689. .nav_Input .el-tree-node__expand-icon.is-leaf{
  690. color: transparent !important;
  691. cursor: default !important
  692. }
  693. </style>