useCasePage.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <div id="init-window" style="position:relative; min-height:95vh; background:#F2F3F6;">
  3. <router-view />
  4. <div v-show="div1" 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;" @click="click_fa">
  9. <br>
  10. <p v-show="node_Data" style="color: #DCDFE6; margin: 100% 0;font-size:14px; text-align:center;" @click="createFolder">新建文件夹</p>
  11. <el-tree
  12. v-if="dataShow"
  13. :data="data1"
  14. node-key="id"
  15. draggable
  16. :expand-on-click-node="false"
  17. :default-expanded-keys="[1]"
  18. :default-checked-keys="[5]"
  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" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" @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-upload
  87. class="upload-demo"
  88. action="https://jsonplaceholder.typicode.com/posts/"
  89. :on-success="handlePreview"
  90. multiple
  91. :limit="3"
  92. :file-list="fileList"
  93. >
  94. <el-button size="small" type="primary">点击上传</el-button>
  95. </el-upload>
  96. <el-button type="primary" style="margin-left:1%;width:10%;" @click="uploadFile()">导入</el-button>
  97. <el-tooltip class="item" effect="light" content="导出勾选项,没有勾选将导出模版" placement="top">
  98. <el-button style="margin-left:2%;width:10%;" @click="exportExcel">导出</el-button>
  99. </el-tooltip>
  100. <!-- 主页table -->
  101. <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">
  102. <el-table-column type="selection" min-width="50" align="center" @change="clickAllData(gridData)" />
  103. <el-table-column prop="id" label="序列号" min-width="80" align="center">
  104. <template slot-scope="scope">{{ scope.row.id }}</template>
  105. </el-table-column>
  106. <el-table-column prop="caseCondition" :show-overflow-tooltip="true" label="用例名称" min-width="240" align="center">
  107. <template slot-scope="scope"><span style="color:#409EFF; cursor: pointer" @click="queryUpdateCreatd(scope.row, 1)">{{ scope.row.title }}</span></template>
  108. </el-table-column>
  109. <el-table-column prop="casePriority" label="优先级" min-width="80" align="center">
  110. <template slot-scope="scope">{{ scope.row.casePriorityName }}</template>
  111. </el-table-column>
  112. <el-table-column prop="creatorName" label="操作人" min-width="110" align="center">
  113. <template slot-scope="scope">{{ scope.row.modifier }}</template>
  114. </el-table-column>
  115. <el-table-column label="操作" min-width="150px" align="center">
  116. <template slot-scope="scope">
  117. <!-- <el-button size="mini" class="btn_query" plain @click="queryUpdateCreatd(scope.row, 1)">查看</el-button> -->
  118. <el-button size="mini" type="primary" plain @click="queryUpdateCreatd(scope.row, 2)">编辑</el-button>
  119. <el-button size="mini" type="danger" plain @click="deleteCaseData(scope.row.id)">删除</el-button>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <!-- 导出文件内容 -->
  124. <el-table v-show="false" id="out-table" :data="tableData" tooltip-effect="dark" style="width: 100%">
  125. <el-table-column prop="id" label="序号" width="50" />
  126. <el-table-column prop="caseCondition" label="前置条件" />
  127. <el-table-column prop="description" label="测试步骤" />
  128. <el-table-column prop="expectedResult" label="期望结果" />
  129. <el-table-column prop="api" label="对应api" />
  130. <el-table-column prop="accessory" label="附件" />
  131. <el-table-column prop="casePriority" label="用例优先级" />
  132. <el-table-column prop="remark" label="备注" />
  133. </el-table>
  134. <div align="center" class="block">
  135. <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" />
  136. </div>
  137. </el-main>
  138. </el-container>
  139. </el-container>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import { createFolderData, queryAllFolderData, queryCasesData, deleteFolderData, deleteCaseData, updateFolderData, caseUpdateFolderName } from '@/api/caseProject.js'
  146. import { mockUrl } from '@/apiConfig/api'
  147. import FileSaver from 'file-saver'
  148. import axios from 'axios'
  149. import XLSX from 'xlsx'
  150. import Utils from '../../util.js'
  151. export default {
  152. name: 'UseCasePage',
  153. data() {
  154. return {
  155. fileList: [],
  156. div1: true,
  157. id: '',
  158. label: '',
  159. node_Name: {},
  160. Folder_Show: false,
  161. add_Folder: '',
  162. node_Data: false,
  163. dataShow: true,
  164. priorityStrings: [{ name: 'p0', value: 0 }, { name: 'p1', value: 1 }, { name: 'p2', value: 2 }, { name: 'p3', value: 3 }],
  165. userInformation: localStorage.getItem('username'),
  166. userNames: localStorage.getItem('realname'),
  167. bizJson: localStorage.getItem('key'),
  168. userData: '',
  169. caseInfo: '',
  170. pageSize: 5,
  171. curIndex: 1,
  172. startId: '',
  173. created_id: '-1',
  174. end: '',
  175. total: 0,
  176. createParticipation: {},
  177. moduleTypeStr: [],
  178. gridData: [],
  179. formData: {},
  180. data1: [],
  181. tableData: [],
  182. imFile: '',
  183. failNum: '',
  184. successNum: '',
  185. startKey: '',
  186. obj: '',
  187. end_Data: '',
  188. return_URL: ''
  189. }
  190. },
  191. created() {
  192. // this.moduleTypeArr()
  193. },
  194. mounted() {
  195. var that = this
  196. Utils.$on('demo', function(msg) {
  197. that.AllQueryFolderData(msg)
  198. })
  199. this.imFile = document.getElementById('imFile')
  200. this.initWindow()
  201. this.AllQueryFolderData(localStorage.getItem('key'))
  202. },
  203. methods: {
  204. handleRemove(file, fileList) {
  205. console.log(file, fileList)
  206. },
  207. handlePreview(file) {
  208. console.log(file)
  209. },
  210. handleExceed(files, fileList) {
  211. this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
  212. },
  213. beforeRemove(file, fileList) {
  214. return this.$confirm(`确定移除 ${file.name}?`)
  215. },
  216. // 左侧导航栏
  217. AllQueryFolderData(e) {
  218. if (e !== '') {
  219. this.gridData = []
  220. this.data1 = []
  221. this.formData = { bizId: e }
  222. queryAllFolderData(this.formData).then(res => {
  223. if (res.code === 200) {
  224. for (var ele of res.data) {
  225. var arr = {}
  226. arr.id = ele.id
  227. arr.label = ele.folderName
  228. arr.children = []
  229. if (ele.subCaseFolderInfos !== null) {
  230. for (var vel of ele.subCaseFolderInfos) {
  231. var add = {}
  232. add.id = vel.id
  233. add.label = vel.folderName
  234. add.children = []
  235. if (vel.subCaseFolderInfos !== null) {
  236. for (var v of vel.subCaseFolderInfos) {
  237. var as = {}
  238. as.id = v.id
  239. as.label = v.folderName
  240. as.children = []
  241. if (v.subCaseFolderInfos != null) {
  242. for (var a of v.subCaseFolderInfos) {
  243. var add4 = {}
  244. add4.id = a.id
  245. add4.label = a.folderName
  246. as.children.push(add4)
  247. }
  248. }
  249. add.children.push(as)
  250. }
  251. }
  252. arr.children.push(add)
  253. }
  254. }
  255. this.data1.push(arr)
  256. }
  257. if (this.data1.length === 0) {
  258. this.node_Data = true
  259. this.dataShow = false
  260. } else {
  261. this.node_Data = false
  262. this.dataShow = true
  263. }
  264. } else {
  265. this.dataShow = false
  266. this.node_Data = true
  267. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  268. }
  269. })
  270. } else {
  271. this.dataShow = false
  272. this.node_Data = true
  273. this.$message({ message: '请先选择业务线', type: 'error', duration: 1000, offset: 150 })
  274. }
  275. },
  276. // 双击编辑
  277. dblclick(data) {
  278. this.label = data.label// 当前选中的名称
  279. this.id = data.id // 当前选中id
  280. this.$set(data, 'label', '')
  281. this.$set(data, 'que', true)
  282. this.$set(data, 'del', false)
  283. this.$set(this.node_Name, 'name', this.label)
  284. setTimeout(() => { this.$refs.get_Input.focus() }, 100)
  285. this.$nextTick(() => {
  286. this.$refs.get_Input.focus()
  287. })
  288. },
  289. // 添加节点
  290. append(data) {
  291. console.log(data)
  292. var id = 1
  293. const newChild = { id: id++, label: '新建子节点', children: [] }
  294. if (!data.children) {
  295. this.$set(data, 'children', [])
  296. }
  297. data.children.push(newChild)
  298. this.formData = {
  299. bizId: this.bizJson,
  300. folderName: newChild.label,
  301. xmindUrl: '',
  302. parentFolderId: this.startId,
  303. creator: this.userInformation,
  304. modifier: this.userInformation
  305. }
  306. createFolderData(this.formData).then(res => {
  307. // if (res.code === 200) {
  308. // this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  309. // this.data1 = []
  310. // this.AllQueryFolderData(this.bizJson)
  311. // this.add_Folder = ''
  312. // } else {
  313. // this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  314. // this.add_Folder = ''
  315. // }
  316. })
  317. },
  318. // 更新节点
  319. queryNodeName(val, data) {
  320. var mun = ''
  321. for (var el of this.data1) { // 最外层id
  322. if (data.id === el.id) { // 双击获取的ID和最外层的ID匹配
  323. mun = '-1' // 有赋值为 -1
  324. } else {
  325. mun = '' // 没有赋值为点击的父元素
  326. }
  327. }
  328. if (val === '') { // 判断用户是否有输入
  329. val = this.label // 没有输入拿之前的label替代
  330. this.end_Data = { parentFolderId: mun, folderName: val, xmindUrl: '', id: data.id, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation }
  331. } else {
  332. this.end_Data = { parentFolderId: mun, folderName: val, xmindUrl: '', id: data.id, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation }
  333. }
  334. this.$set(data, 'que', false) // 失去焦点隐藏input
  335. this.$set(this.node_Name, 'name', '') // 清空input
  336. caseUpdateFolderName(this.end_Data).then(res => {
  337. if (res.code === 200) {
  338. this.$message({ type: 'success', message: res.msg, duration: 1000 })
  339. this.data1 = []
  340. this.AllQueryFolderData(localStorage.getItem('key'))
  341. } else {
  342. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  343. this.data1 = []
  344. this.AllQueryFolderData(localStorage.getItem('key'))
  345. }
  346. })
  347. },
  348. // 显示隐藏删除图标
  349. mouseenter(data) {
  350. this.$set(data, 'del', true)
  351. },
  352. mouseleave(data) {
  353. this.$set(data, 'del', false)
  354. },
  355. // 隐藏主页样式
  356. initWindow() {
  357. if (!document.getElementById('window-judge')) {
  358. document.getElementById('init-window').parentNode.style.overflow = 'auto'
  359. } else {
  360. document.getElementById('init-window').parentNode.style.overflow = 'hidden'
  361. }
  362. },
  363. // moduleTypeArr() {
  364. // axios.get('https://star.xiaojukeji.com/upload/getPresignedUrl.node?name=“文件名”').then(res => {
  365. // console.log(res)
  366. // })
  367. // settingQueryModuleInfoListData(this.formData).then(res => {
  368. // this.moduleTypeStr = res.data
  369. // })
  370. // },
  371. handleSizeChange(size) {
  372. this.pageSize = size
  373. this.pageIndex()
  374. },
  375. handleCurrentChange(curIndex) {
  376. this.curIndex = curIndex
  377. this.pageIndex()
  378. },
  379. pageIndex() {
  380. this.formData = {
  381. pageSize: this.pageSize,
  382. curIndex: this.curIndex,
  383. caseFolderId: this.startId
  384. }
  385. queryCasesData(this.formData).then(res => {
  386. this.gridData = res.data.list
  387. })
  388. },
  389. clickAllData(rows) {
  390. this.formData = {
  391. caseFolderId: this.startId
  392. }
  393. queryCasesData(this.formData).then(res => {
  394. this.tableData = res.data
  395. })
  396. },
  397. // 点击空白创建最外层nav
  398. click_fa() {
  399. this.created_id = '-1'
  400. },
  401. // 新建文件夹
  402. createFolder() {
  403. this.Folder_Show = true
  404. this.add_Folder = ''
  405. this.node_Data = false
  406. setTimeout(() => { this.$refs.input1.focus() }, 100)
  407. },
  408. // input失去焦点新增(或取消)
  409. hide_input(vel) {
  410. if (vel !== '') {
  411. this.created_id === '' ? this.created_id = '-1' : ''
  412. this.formData = {
  413. bizId: this.bizJson,
  414. folderName: vel,
  415. xmindUrl: '',
  416. parentFolderId: this.created_id,
  417. creator: this.userInformation,
  418. modifier: this.userInformation
  419. }
  420. createFolderData(this.formData).then(res => {
  421. if (res.code === 200) {
  422. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  423. // this.createCaseCode = false
  424. this.dataShow = true
  425. this.node_Data = false
  426. this.data1 = []
  427. this.AllQueryFolderData(this.bizJson)
  428. this.created_id = ''
  429. } else {
  430. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  431. this.created_id = ''
  432. }
  433. })
  434. this.Folder_Show = false
  435. } else {
  436. this.$message({ message: '取消创建文件夹', type: 'success', duration: 1000, offset: 150 })
  437. this.Folder_Show = false
  438. this.node_Data = true
  439. }
  440. },
  441. // 查询
  442. queryCaseData(ele) {
  443. if (this.createParticipation.caseName === '') return false
  444. if (this.startId === '') {
  445. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  446. } else {
  447. this.createParticipation = ele
  448. this.createParticipation.caseFolderId = this.startId
  449. this.createParticipation.pageSize = this.pageSize
  450. this.createParticipation.curIndex = this.curIndex
  451. queryCasesData(this.createParticipation).then(res => {
  452. this.gridData = res.data.list
  453. })
  454. }
  455. },
  456. queryUpdateCreatd(ele, e) {
  457. if (this.startId === '') {
  458. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  459. } else {
  460. switch (e) {
  461. case 1: // 查看
  462. this.$router.push({ path: '/Platform/useCasePage/queryUse', query: { id: ele.id, caseFolderId: ele.caseFolderId }})
  463. break
  464. case 2: // 编辑
  465. // this.div1 = false
  466. this.$router.push({ path: '/Platform/useCasePage/createUse', query: { id: ele.id, caseFolderId: ele.caseFolderId }})
  467. break
  468. case 3: // 新增
  469. this.$router.push({ path: '/Platform/useCasePage/createUse', query: { data: this.startId }})
  470. break
  471. }
  472. }
  473. },
  474. handleSelectionChange(val) {
  475. this.tableData = val
  476. },
  477. // nav
  478. handleDragStart(node, ev) {
  479. console.log('节点开始拖拽时触发的事件', node.key)
  480. this.startKey = node.key
  481. },
  482. handleDragEnter(draggingNode, dropNode, ev) {
  483. console.log('拖拽进入其他节点时触发的事件', dropNode.data.id)
  484. },
  485. handleDragLeave(draggingNode, dropNode, ev) {
  486. console.log('拖拽离开某个节点时触发的事件', dropNode.data.id)
  487. },
  488. handleDragOver(draggingNode, dropNode, ev) {
  489. console.log('在拖拽节点时触发的事件', dropNode.data.id)
  490. },
  491. handleDragEnd(draggingNode, dropNode, dropType, ev) {
  492. console.log('拖拽结束时(可能未成功)触发的事件', dropNode && dropNode.key, dropType)
  493. },
  494. handleDrop(draggingNode, dropNode, dropType, ev) {
  495. console.log('拖拽成功完成时触发的事件', dropNode.key, dropType)
  496. var startEnd = { parentFolderId: dropNode.key, id: this.startKey, bizId: localStorage.getItem('key'), modifier: this.userInformation, creator: this.userInformation, xmindUrl: '' }
  497. this.ConfirmSubmission(startEnd)
  498. },
  499. ConfirmSubmission(vel) {
  500. updateFolderData(vel).then(res => {
  501. if (res.code === 200) {
  502. this.$message({ type: 'success', message: res.msg, duration: 1000 })
  503. this.data1 = []
  504. this.AllQueryFolderData(localStorage.getItem('key'))
  505. } else {
  506. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  507. this.data1 = []
  508. this.AllQueryFolderData(localStorage.getItem('key'))
  509. }
  510. })
  511. },
  512. // 删除
  513. remove(node, data) {
  514. this.$confirm('是否确认删除', '确认信息', {
  515. distinguishCancelAndClose: true,
  516. confirmButtonText: '确定',
  517. cancelButtonText: '取消'
  518. })
  519. .then(() => {
  520. this.formData = {
  521. id: node.data.id,
  522. modifier: node.data.id
  523. }
  524. deleteFolderData(this.formData).then(res => {
  525. if (res.code === 200) {
  526. this.$message({ type: 'success', message: '已删除' })
  527. this.data1 = []
  528. this.AllQueryFolderData(localStorage.getItem('key'))
  529. } else {
  530. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  531. }
  532. })
  533. })
  534. .catch(action => {
  535. this.$message({ type: 'success', message: '已取消' })
  536. })
  537. },
  538. // Nav 当前点击
  539. clickFun(e) {
  540. this.startId = e.id
  541. this.created_id = e.id
  542. this.formData = {
  543. pageSize: 5,
  544. curIndex: 1,
  545. caseFolderId: e.id
  546. }
  547. queryCasesData(this.formData).then(res => {
  548. this.gridData = res.data.list
  549. this.total = res.data.total
  550. })
  551. },
  552. // 表格信息删除
  553. deleteCaseData(e) {
  554. if (this.startId === '') {
  555. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  556. } else {
  557. this.$confirm('是否确认删除', '确认信息', {
  558. distinguishCancelAndClose: true,
  559. confirmButtonText: '确定',
  560. cancelButtonText: '取消'
  561. })
  562. .then(() => {
  563. this.caseInfo = { id: e, modifier: this.userInformation }
  564. deleteCaseData(this.caseInfo).then(res => {
  565. if (res.code === 200) {
  566. var data = {
  567. pageSize: this.pageSize,
  568. curIndex: this.curIndex,
  569. caseFolderId: this.startId
  570. }
  571. queryCasesData(data).then(res => {
  572. this.gridData = res.data.list
  573. this.$message({ type: 'success', message: '已删除' })
  574. })
  575. } else {
  576. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  577. }
  578. })
  579. })
  580. .catch(action => { this.$message({ type: 'success', message: '已取消' }) })
  581. }
  582. },
  583. // 导出
  584. exportExcel() {
  585. if (this.startId === '') {
  586. this.$message({ message: '提示,👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  587. } else {
  588. /* generate workbook object from table */
  589. var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
  590. /* get binary string as output */
  591. var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
  592. try {
  593. FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
  594. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  595. return wbout
  596. }
  597. },
  598. // 导入excel
  599. importFile() {
  600. var obj = this.imFile
  601. if (!obj.files) {
  602. return
  603. }
  604. var f = obj.files[0]
  605. var formData = new FormData()
  606. formData.append('file', f)
  607. // var tow = f.name.split('.')
  608. // axios.post('https://star.xiaojukeji.com/upload/getPresignedUrl.node?name=' + tow[0] + '&customAcl=public-read&cacheStrategy=max-age=31536000', {
  609. // // 单独配置
  610. // withCredentials: false
  611. // })
  612. // .then(function(res) {
  613. // console.log(res.data)
  614. // this.return_URL = res.data.url
  615. // axios.post(this.return_URL, formData).then(res => {
  616. // console.log(res)
  617. // })
  618. // })
  619. // .catch(function(err) {
  620. // console.error('1' + err)
  621. // })
  622. var caseInfo = {
  623. bizId: this.bizJson,
  624. creator: this.userNames,
  625. modifier: this.userNames,
  626. caseFolderId: this.startId
  627. }
  628. formData.append('caseInfo', JSON.stringify(caseInfo))
  629. const config = {
  630. headers: { 'Content-Type': 'multipart/form-data' }
  631. }
  632. axios.post(mockUrl + '/case/uploadCase', formData, config).then(res => {
  633. var code = res.data.data
  634. this.successNum = code.successNum
  635. this.failNum = code.failNum
  636. console.log(res)
  637. if (res.data.code === 200) {
  638. if (this.failNum === 0) {
  639. this.updateCaseListData()
  640. } else {
  641. this.haha = '上传成功' + this.successNum + '上传失败' + this.failNum
  642. this.$notify({ title: 'error', message: this.haha, type: 'success', duration: 2000 })
  643. }
  644. this.$refs.imFile.value = null
  645. } else {
  646. this.$message({ type: 'success', message: '导入失败' })
  647. }
  648. })
  649. },
  650. // fixdata: function(data) { // 文件流转BinaryString
  651. // var o = ''
  652. // var l = 0
  653. // var w = 10240
  654. // for (; l < data.byteLength / w; ++l) {
  655. // o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
  656. // }
  657. // o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
  658. // return o
  659. // },
  660. // 按钮导入
  661. uploadFile() {
  662. if (this.startId === '') {
  663. this.$message({ message: '提示,👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  664. } else {
  665. this.$refs.imFile.click()
  666. }
  667. },
  668. updateCaseListData() {
  669. this.createParticipation.caseFolderId = this.startId
  670. queryCasesData(this.createParticipation).then(res => {
  671. this.gridData = res.data
  672. this.$message({ type: res.msg, message: res.msg, duration: 1000 })
  673. })
  674. }
  675. }
  676. }
  677. </script>
  678. <style>
  679. .custom-tree-node {
  680. flex: 1;
  681. display: flex;
  682. align-items: center;
  683. justify-content: space-between;
  684. font-size: 14px;
  685. padding-right: 8px;
  686. }
  687. .nav_Input .el-input--mini .el-input__inner {
  688. height: 23px !important;
  689. }
  690. .span_el {
  691. display: block;
  692. overflow: hidden;
  693. /* white-space: nowrap; */
  694. text-overflow: ellipsis;
  695. }
  696. .btn_query .el-button--primary.is-plain {
  697. color: #000000 !important;
  698. background: #F9F9FA !important;
  699. border-color: #F9F9FA !important;
  700. }
  701. .button_query :hover{
  702. background: #409EFF;
  703. color: #FFFFFF;
  704. }
  705. </style>