testPage.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <!-- 测试计划管理 -->
  3. <div id="init-window" style="position:relative; min-height:95vh; font-size:14px background:#F2F3F6;">
  4. <router-view />
  5. <div style="position: absolute;width: 100%;">
  6. <div style="background:#F2F3F6;">
  7. <el-container>
  8. <el-aside width="17%" style=" background: #FFF;margin: 1% 0 1% 1%; border-radius:8px;">
  9. <div class="nav_Input" style="min-height:90vh;">
  10. <br>
  11. <el-tree :data="data1" :default-expanded-keys="key_arr" :expand-on-click-node="true" node-key="id" @node-click="clickFun">
  12. <span slot-scope="{ node, data }" style="width:100%;" class="custom-tree-node" @mouseenter="mouseenter(data)" @mouseleave="mouseleave(data)">
  13. <span :title="data.label" class="span_el">{{ node.label }}</span>
  14. <el-dropdown v-show="data.del" style="margin-left:10px" trigger="click">
  15. <span v-show="data.codes === '1' ? false : true" class="el-dropdown-link">
  16. ···<i class="el-icon--right" />
  17. </span>
  18. <el-dropdown-menu slot="dropdown">
  19. <el-dropdown-item v-show="data.codes !== '2'" @click.native="dblclick(data)">编辑测试计划</el-dropdown-item>
  20. <el-dropdown-item v-show="data.codes !== '2'" @click.native="() => remove(node, data)">删除测试计划</el-dropdown-item>
  21. <el-dropdown-item v-show="data.codes === '2'" @click.native="createdTest(data)">新建测试计划</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </span>
  25. </el-tree>
  26. </div>
  27. </el-aside>
  28. <el-container>
  29. <el-header style="background:#ffffff; height: auto; width: 98%; margin: 1%; font-size: 13px; border-radius: 8px;">
  30. <el-row>
  31. <el-col :span="24" style="white-space:nowrap; display: flex; justify-content: center; align-items: center;">
  32. 序列号
  33. <el-input v-model="test_plan.id" clearable placeholder="请填写" style="width: 20%; margin: 3% 2%" />
  34. 测试计划状态
  35. <el-select v-model="test_plan.region" clearable placeholder="请选择" style="width: 20%; margin: 3% 2%">
  36. <el-option v-for="item in projectTypeStrings" :key="item.code" :label="item.msg" :value="item.code" />
  37. </el-select>
  38. <el-button type="primary" @click="queryCaseData(test_plan)">查询</el-button>
  39. <el-button type="primary" style="margin: 3% 2%" @click="createGetShow">新增</el-button>
  40. <el-button @click="implement">执行结果</el-button>
  41. </el-col>
  42. </el-row>
  43. </el-header>
  44. <div style="background:#ffffff; width: 98%; margin: 0 1% 1% 1%; font-size: 14px; border-radius: 8px;">
  45. <el-row :gutter="20" style="margin: 3%;text-align:center">
  46. <el-col :span="6" style="border-right: 1px solid #D8D8D8; color:#07BCA4;"><img :src="clicked_1" style="margin-right: 6%;width:5%;">通过 {{ num.Count1 }} 个, 占比 {{ num.Rate1 }} %</el-col>
  47. <el-col :span="6" style="border-right: 1px solid #D8D8D8; color:#F56C6C;"><img :src="clicked_2" style="margin-right: 6%;width:5%;">失败 {{ num.Count2 }} 个, 占比 {{ num.Rate2 }} %</el-col>
  48. <el-col :span="6" style="border-right: 1px solid #D8D8D8; color:#F5A623;"><img :src="clicked_3" style="margin-right: 6%;width:5%;">阻塞 {{ num.Count3 }} 个, 占比 {{ num.Rate3 }} %</el-col>
  49. <el-col :span="6" style=" color:#73C5FA;"><img :src="clicked_4" style="margin-right: 6%;width:5%;">未执行{{ num.Count4 }}个,占比{{ num.Rate4 }}%</el-col>
  50. </el-row>
  51. </div>
  52. <el-main style="background:#ffffff; width:98%;margin:0% 1% 1% 1%; font-size:14px;border-radius:8px;"><!-- 主页table -->
  53. <el-table :data="gridData" :header-cell-style="{ background: '#F0F2F4', color: '#333B4A' }" border fit tooltip-effect="dark" size="mini" style="width: 100%">
  54. <el-table-column prop="id" label="序列号" min-width="100" align="center"><template slot-scope="scope">{{ scope.row.ids }}</template></el-table-column>
  55. <el-table-column prop="caseName" label="用例名" min-width="200" align="center">
  56. <template slot-scope="scope"><span style="color:#409EFF; cursor: pointer" @click="go_query(scope.row)">{{ scope.row.title }}</span></template>
  57. </el-table-column>
  58. <el-table-column prop="creatorName" label="执行状态" min-width="100" align="center">
  59. <template slot-scope="scope">
  60. <el-row :gutter="20" style="margin: 3%;text-align:center">
  61. <el-col :span="6"><img style=" cursor: pointer;" :src="scope.row.keys === 1 ? clicked_1: Unclicked_1" @click="Unclicked(clicked_1, scope.$index, scope.row )"></el-col>
  62. <el-col :span="6"><img style=" cursor: pointer;" :src="scope.row.keys === 2 ? clicked_2: Unclicked_2" @click="Unclicked2(clicked_2, scope.$index, scope.row)"></el-col>
  63. <el-col :span="6"><img style=" cursor: pointer;" :src="scope.row.keys === 3 ? clicked_3: Unclicked_3" @click="Unclicked3(clicked_3, scope.$index, scope.row)"></el-col>
  64. <el-col :span="6"><img style=" cursor: pointer;" :src="scope.row.keys === 0 ? clicked_4: Unclicked_4" @click="Unclicked4(clicked_4, scope.$index, scope.row)"></el-col>
  65. </el-row>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作" min-width="200" align="center" fixed="right">
  69. <template slot-scope="scope">
  70. <el-button size="mini" type="primary" plain @click="go_Bug(scope.row)">提bug</el-button>
  71. <el-button size="mini" type="danger" plain @click="deleteCaseData(scope.row)">删除</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <div align="center"> <!--分页-->
  76. <el-pagination :current-page="curIndex" :page-size="pageSize" :hide-on-single-page="true" background layout="total, prev, pager, next" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  77. </div>
  78. </el-main>
  79. </el-container>
  80. </el-container>
  81. <!-- 新建测试计划 -->
  82. <el-dialog title="新建测试计划" :visible.sync="dialogFormVisibleUpdate" width="30%" center>
  83. <el-form ref="caseData" label-position="left" :model="caseData" label-width="120px" :rules="createFormData">
  84. <el-form-item label="测试计划名称" prop="testPlanName">
  85. <el-input v-model="caseData.testPlanName" clearable autocomplete="off" placeholder="请输入测试计划名称" style="width: 90%" />
  86. </el-form-item>
  87. <el-form-item label="测试计划类型" prop="projectType">
  88. <el-select v-model="caseData.caserojectType" placeholder="请选择【准入计划】【非准入计划】" style="width: 90%">
  89. <el-option v-for="item in testPlanTypeEnum" :key="item.code" :label="item.msg" :value="item.code" />
  90. </el-select>
  91. </el-form-item>
  92. <el-form-item label="端类型" prop="taskType">
  93. <el-select v-model="caseData.taskType" placeholder="请选择【服务端】【客户端】" style="width: 90%">
  94. <el-option v-for="item in taskTypeStrings" :key="item.code" :label="item.msg" :value="item.code" />
  95. </el-select>
  96. </el-form-item>
  97. <!-- <el-form-item label="工程模块" prop="casePriority">
  98. <el-select v-model="caseData.casePriority" clearable placeholder="请选择【多选组件】" style="width: 90%">
  99. <el-option v-for="item in priorityStrings" :key="item.value" :label="item.name" :value="item.value" />
  100. </el-select>
  101. </el-form-item> -->
  102. </el-form>
  103. <div slot="footer" class="dialog-footer">
  104. <el-button @click="caseCreateCase(caseData, titleName)">确 定</el-button>
  105. <el-button type="danger" @click="dialogFormVisibleUpdate = false">关 闭</el-button>
  106. </div>
  107. </el-dialog>
  108. <el-dialog :visible.sync="dialogFormVisibleUpdateOne" width="70%" center>
  109. <el-row :gutter="20">
  110. <el-col :span="4" style="text-align:right; margin-top:0.7%;"><strong>用例目录</strong></el-col>
  111. <el-col :span="4">
  112. <el-select v-model="case_from.one" size="small" clearable placeholder="请选择" @change="case_fromOne(case_from.one)">
  113. <el-option v-for="item in case_one" :key="item.id" :label="item.label" :value="item.id" />
  114. </el-select>
  115. </el-col>
  116. <el-col v-if="caseShwo_two" :span="4">
  117. <el-select v-model="case_from.two" size="small" clearable placeholder="请选择" @change="case_fromTwo(case_from.two)">
  118. <el-option v-for="item in case_two" :key="item.id" :label="item.label" :value="item.id" />
  119. </el-select>
  120. </el-col>
  121. <el-col v-if="caseShwo_three" :span="4">
  122. <el-select v-model="case_from.three" size="small" clearable placeholder="请选择" @change="case_fromThree(case_from.three)">
  123. <el-option v-for="item in case_three" :key="item.id" :label="item.label" :value="item.id" />
  124. </el-select>
  125. </el-col>
  126. <el-col v-if="caseShwo_four" :span="4">
  127. <el-select v-model="case_from.four" size="small" clearable placeholder="请选择" @change="case_fromFour(case_from.four)">
  128. <el-option v-for="item in case_four" :key="item.id" :label="item.label" :value="item.id" />
  129. </el-select>
  130. </el-col>
  131. </el-row>
  132. <div align="center">
  133. <el-table :data="grid_Data" :header-cell-style="{ background: '#F0F2F4', color: '#333B4A' }" border tooltip-effect="dark" size="mini" style="width: 83%; margin:2% 0;" @selection-change="handleSelectionChange">
  134. <el-table-column type="selection" min-width="50" align="center" @change="clickAllData(grid_Data)" />
  135. <el-table-column prop="id" label="序列号" min-width="80" align="center">
  136. <template slot-scope="scope">{{ scope.row.id }}</template>
  137. </el-table-column>
  138. <el-table-column prop="caseCondition" :show-overflow-tooltip="true" label="用例名称" min-width="240" align="center">
  139. <template slot-scope="scope">{{ scope.row.title }}</template>
  140. </el-table-column>
  141. <el-table-column prop="casePriority" label="优先级" min-width="80" align="center">
  142. <template slot-scope="scope">{{ scope.row.casePriorityName }}</template>
  143. </el-table-column>
  144. <el-table-column prop="creatorName" label="操作人" min-width="110" align="center">
  145. <template slot-scope="scope">{{ scope.row.modifier }}</template>
  146. </el-table-column>
  147. </el-table>
  148. <el-pagination :current-page="curIndex" :page-sizes="[5, 10, 20]" :page-size="pageSize" layout="total, prev, pager, next" :total="total" background :hide-on-single-page="true" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  149. </div>
  150. <div slot="footer" class="dialog-footer">
  151. <el-button size="small" @click="case_CreateCase()">保 存</el-button>
  152. <el-button size="small" type="danger" @click="dialogFormVisibleUpdateOne = false">取 消</el-button>
  153. </div>
  154. </el-dialog>
  155. </div>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { queryCasesData, createTestPlan, updateTestPlan, deleteTestPlanCase, deleteTestPlan, updateTestPlanCase, queryTestPlanTree, queryTestPlanCaseList, queryAllFolderData, createTestPlanCaseList, getWebShowMap, passRateOfTestPlan } from '@/api/caseProject.js'
  161. import clicked_1 from '@/assets/通过点击后状态.png'
  162. import clicked_2 from '@/assets/失败点击后状态.png'
  163. import clicked_3 from '@/assets/阻塞点击后状态.png'
  164. import clicked_4 from '@/assets/未执行点击后状态.png'
  165. import Unclicked_1 from '@/assets/通过未点击状态.png'
  166. import Unclicked_2 from '@/assets/失败未点击状态.png'
  167. import Unclicked_3 from '@/assets/阻塞未点击状态.png'
  168. import Unclicked_4 from '@/assets/未执行未点击状态.png'
  169. export default {
  170. name: 'Testpage',
  171. data() {
  172. return {
  173. test_plan: {},
  174. caseShwo_two: false,
  175. caseShwo_three: false,
  176. caseShwo_four: false,
  177. titleName: '',
  178. num: {},
  179. clicked_1: clicked_1,
  180. clicked_2: clicked_2,
  181. clicked_3: clicked_3,
  182. clicked_4: clicked_4,
  183. Unclicked_1: Unclicked_1,
  184. Unclicked_2: Unclicked_2,
  185. Unclicked_3: Unclicked_3,
  186. Unclicked_4: Unclicked_4,
  187. dialogFormVisibleUpdate: false,
  188. dialogFormVisibleUpdateOne: false,
  189. testPlanTypeEnum: [],
  190. projectTypeStrings: [],
  191. taskTypeStrings: [],
  192. userInformation: localStorage.getItem('username'),
  193. bizJson: localStorage.getItem('key'),
  194. createTimeData: '',
  195. pageSize: 8,
  196. curIndex: 1,
  197. startId: '',
  198. Parentids: '',
  199. createParticipation: {},
  200. gridData: [],
  201. pegs: '',
  202. caseData: {
  203. caserojectType: 2,
  204. taskType: 2
  205. },
  206. createFormData: {
  207. testPlanName: [{ required: true, message: '测试计划名称不能为空', trigger: 'change' }],
  208. caserojectType: [{ required: true, message: '测试计划类型不能为空', trigger: 'change' }]
  209. },
  210. dialogTableVisible: false,
  211. formData: {},
  212. taskids: '',
  213. data1: [],
  214. data2: [],
  215. total: 0,
  216. excelData: [],
  217. imFile: '',
  218. failNum: '',
  219. successNum: '',
  220. startKey: '',
  221. obj: '',
  222. grid_Data: [],
  223. case_from: {},
  224. case_one: [],
  225. case_two: [],
  226. case_three: [],
  227. case_four: [],
  228. add_Folder: {},
  229. Selection: [],
  230. key_arr: [],
  231. arr: {},
  232. add: {},
  233. as: {}
  234. }
  235. },
  236. created() {
  237. this.AllQueryFolderData()
  238. this.caseFolder_Nav()
  239. this.get_selectData()
  240. },
  241. mounted() {
  242. this.imFile = document.getElementById('imFile')
  243. },
  244. methods: {
  245. // init初始化
  246. AllQueryFolderData() {
  247. queryTestPlanTree({ bizId: localStorage.getItem('key') }).then(res => {
  248. if (res.code === 200) {
  249. this.data1 = res.data.map(item => ({
  250. ...item,
  251. codes: '1',
  252. projectIds: item.id,
  253. label: item.projectName,
  254. children: item.taskNameMapList.map(eachData => ({
  255. ...eachData,
  256. Parentids: item.id,
  257. codes: '2',
  258. label: eachData.taskName,
  259. children: eachData.testPlanInfos.map(key => ({
  260. ...key,
  261. codes: '3',
  262. taskids: eachData.id,
  263. label: key.testPlanName
  264. }))
  265. }))
  266. }))
  267. } else {
  268. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  269. }
  270. })
  271. },
  272. caseFolder_Nav() {
  273. queryAllFolderData({ bizId: localStorage.getItem('key') }).then(res => {
  274. if (res.code === 200) {
  275. for (var ele of res.data) {
  276. this.arr = {}
  277. this.arr.id = ele.id
  278. this.arr.label = ele.folderName
  279. this.arr.children = []
  280. if (ele.subCaseFolderInfos !== null) {
  281. for (var vel of ele.subCaseFolderInfos) {
  282. this.add = {}
  283. this.add.id = vel.id
  284. this.add.label = vel.folderName
  285. this.add.children = []
  286. if (vel.subCaseFolderInfos !== null) {
  287. for (var v of vel.subCaseFolderInfos) {
  288. this.as = {}
  289. this.as.id = v.id
  290. this.as.label = v.folderName
  291. this.as.children = []
  292. if (v.subCaseFolderInfos != null) {
  293. for (var a of v.subCaseFolderInfos) {
  294. var add4 = {}
  295. add4.id = a.id
  296. add4.label = a.folderName
  297. this.as.children.push(add4)
  298. }
  299. }
  300. this.add.children.push(this.as)
  301. }
  302. }
  303. this.arr.children.push(this.add)
  304. }
  305. }
  306. this.data2.push(this.arr)
  307. }
  308. } else {
  309. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  310. }
  311. })
  312. },
  313. // 获取下拉数据
  314. get_selectData() {
  315. getWebShowMap().then(res => {
  316. this.projectTypeStrings = res.data.testPlanStatusEnum
  317. this.taskTypeStrings = res.data.clientEnum
  318. this.testPlanTypeEnum = res.data.testPlanTypeEnum
  319. })
  320. },
  321. // 导航栏编辑
  322. dblclick(data) {
  323. this.caseData = data
  324. this.$set(this.caseData, 'testPlanName', data.testPlanName)
  325. this.caseData.caserojectType = data.testPlanType
  326. this.titleName = '编辑'
  327. this.dialogFormVisibleUpdate = true
  328. },
  329. // 导航栏_新增
  330. createdTest(data) {
  331. this.caseData = data
  332. this.$set(this.caseData, 'testPlanName', '')
  333. this.$set(this.caseData, 'caserojectType', 2)
  334. this.$set(this.caseData, 'taskType', 2)
  335. this.titleName = '新增'
  336. // this.$refs['caseData'].clearValidate()
  337. this.dialogFormVisibleUpdate = true
  338. },
  339. // 显示隐藏删除图标
  340. mouseenter(data) {
  341. this.$set(data, 'del', true)
  342. },
  343. mouseleave(data) {
  344. this.$set(data, 'del', false)
  345. },
  346. // 删除
  347. remove(node, data) {
  348. this.$confirm('是否确认删除', '确认信息', {
  349. distinguishCancelAndClose: true,
  350. confirmButtonText: '确定',
  351. cancelButtonText: '取消'
  352. })
  353. .then(() => {
  354. var caseData = {
  355. projectId: data.projectId,
  356. modifier: this.userInformation,
  357. taskId: data.taskId,
  358. bizId: this.bizJson,
  359. id: data.id
  360. }
  361. deleteTestPlan(caseData).then(res => {
  362. if (res.code === 200) {
  363. this.$message({ type: 'success', message: '已删除' })
  364. this.data1 = []
  365. this.AllQueryFolderData()
  366. } else {
  367. this.$message({ type: 'error', message: res.msg, duration: 1000 })
  368. }
  369. })
  370. })
  371. .catch(action => {
  372. this.$message({ type: 'success', message: '已取消' })
  373. })
  374. },
  375. // 分页
  376. handleSizeChange(size) {
  377. this.pageSize = size
  378. this.pageIndex()
  379. },
  380. handleCurrentChange(curIndex) {
  381. this.curIndex = curIndex
  382. this.pageIndex()
  383. },
  384. pageIndex() {
  385. queryTestPlanCaseList({ pageSize: this.pageSize, curIndex: this.curIndex, testPlanId: this.startId }).then(res => {
  386. this.gridData = res.data
  387. })
  388. },
  389. // 新增/编辑 提交
  390. caseCreateCase(vel, e) {
  391. this.key_arr = []
  392. if (e === '编辑') {
  393. var caseData = vel
  394. updateTestPlan(caseData).then(res => {
  395. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  396. this.dialogFormVisibleUpdate = false
  397. this.AllQueryFolderData()
  398. })
  399. }
  400. if (e === '新增') {
  401. this.$refs['caseData'].validate((valid) => {
  402. if (valid) {
  403. caseData = {
  404. caserojectType: vel.caserojectType,
  405. testPlanName: vel.testPlanName,
  406. taskType: vel.taskType,
  407. projectId: vel.Parentids,
  408. creator: this.userInformation,
  409. modifier: this.userInformation,
  410. taskId: vel.id,
  411. bizId: this.bizJson
  412. }
  413. createTestPlan(caseData).then(res => {
  414. if (res.code === 200) {
  415. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  416. this.dialogFormVisibleUpdate = false
  417. this.AllQueryFolderData()
  418. } else {
  419. this.$notify({ title: '提示', message: res.msg, duration: 2000 })
  420. }
  421. })
  422. }
  423. })
  424. }
  425. this.key_arr.push(vel.id)
  426. },
  427. // 查询
  428. queryCaseData(ele) {
  429. if (this.createParticipation.testPlanName === '') return false
  430. if (this.pegs !== '3') {
  431. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  432. } else {
  433. this.createParticipation.testPlanId = this.startId
  434. this.createParticipation.id = ele.id
  435. this.createParticipation.status = ele.region
  436. this.createParticipation.pageSize = this.pageSize
  437. this.createParticipation.curIndex = this.curIndex
  438. queryTestPlanCaseList(this.createParticipation).then(res => {
  439. this.gridData = res.data
  440. this.total = res.data.length
  441. })
  442. }
  443. },
  444. // 新增
  445. createGetShow() {
  446. this.titleName = '新增'
  447. this.case_from = {}
  448. if (this.pegs !== '3') {
  449. this.$message({ message: '提示, 👈请选择目录', type: 'success', duration: 1000, offset: 150 })
  450. } else {
  451. this.dialogFormVisibleUpdateOne = true
  452. this.case_one = this.data2
  453. }
  454. },
  455. // 复选框单选
  456. handleSelectionChange(val) {
  457. this.Selection = []
  458. for (var e of val) {
  459. this.Selection.push(e.id)
  460. }
  461. },
  462. // 新建table保存
  463. case_CreateCase() {
  464. createTestPlanCaseList({ testPlanId: this.startId, caseIds: this.Selection, creator: this.userInformation, modifier: this.userInformation }).then(res => {
  465. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  466. this.dialogFormVisibleUpdateOne = false
  467. })
  468. },
  469. // table全选调用查询接口
  470. clickAllData(rows) {
  471. queryCasesData({ caseFolderId: this.startId }).then(res => {
  472. var table_Data = res.data.list
  473. for (var el of table_Data) {
  474. this.Selection.push(el.id)
  475. }
  476. })
  477. },
  478. // 改变case_one
  479. case_fromOne(e) {
  480. if (e === '') {
  481. this.caseShwo_two = false
  482. this.$set(this.case_from, 'two', '')
  483. this.caseShwo_three = false
  484. this.$set(this.case_from, 'three', '')
  485. this.caseShwo_four = false
  486. this.$set(this.case_from, 'four', '')
  487. this.grid_Data = []
  488. } else {
  489. queryCasesData({ pageSize: this.pageSize, curIndex: this.curIndex, caseFolderId: e }).then(res => {
  490. this.grid_Data = res.data.list
  491. this.total = res.data.total
  492. })
  493. for (var one of this.data2) {
  494. if (one.id === e) {
  495. this.case_two = one.children
  496. if (this.case_two.length !== 0) {
  497. this.caseShwo_two = true
  498. } else {
  499. this.caseShwo_two = false
  500. }
  501. }
  502. }
  503. }
  504. },
  505. // 改变case_two
  506. case_fromTwo(e) {
  507. if (e === '') {
  508. this.caseShwo_three = false
  509. this.$set(this.case_from, 'three', '')
  510. this.caseShwo_four = false
  511. this.$set(this.case_from, 'four', '')
  512. this.grid_Data = []
  513. } else {
  514. queryCasesData({ pageSize: this.pageSize, curIndex: this.curIndex, caseFolderId: e }).then(res => {
  515. this.grid_Data = res.data.list
  516. this.total = res.data.total
  517. })
  518. for (var two of this.case_two) {
  519. if (two.id === e) {
  520. this.case_three = two.children
  521. if (this.case_three.length !== 0) {
  522. this.caseShwo_three = true
  523. } else {
  524. this.caseShwo_three = false
  525. }
  526. }
  527. }
  528. }
  529. },
  530. // 改变case_three
  531. case_fromThree(e) {
  532. if (e === '') {
  533. this.caseShwo_four = false
  534. this.$set(this.case_from, 'four', '')
  535. this.grid_Data = []
  536. } else {
  537. queryCasesData({ pageSize: this.pageSize, curIndex: this.curIndex, caseFolderId: e }).then(res => {
  538. this.grid_Data = res.data.list
  539. this.total = res.data.total
  540. })
  541. for (var three of this.case_three) {
  542. if (three.id === e) {
  543. this.case_four = three.children
  544. if (this.case_four.length !== 0) {
  545. this.caseShwo_four = true
  546. } else {
  547. this.caseShwo_four = false
  548. }
  549. }
  550. }
  551. }
  552. },
  553. // 改变case_four
  554. case_fromFour(e) {
  555. this.grid_Data = []
  556. queryCasesData({ pageSize: this.pageSize, curIndex: this.curIndex, caseFolderId: e }).then(res => {
  557. this.grid_Data = res.data.list
  558. this.total = res.data.total
  559. })
  560. },
  561. // 点击节点
  562. clickFun(e) {
  563. console.log(e)
  564. this.pegs = ''
  565. e.codes === '1' ? this.Parentids = e.id : ''
  566. e.codes === '2' ? this.taskids = e.id : ''
  567. if (e.codes === '3') {
  568. this.pegs = '3'
  569. this.startId = e.id
  570. queryTestPlanCaseList({ pageSize: this.pageSize, curIndex: this.curIndex, testPlanId: e.id }).then(res => {
  571. this.gridData = []
  572. res.data.map(item => {
  573. item.caseInfo.thrr = e.id
  574. item.caseInfo.ids = item.id
  575. item.caseInfo.status_case = item.status
  576. item.caseInfo.keys = item.status
  577. this.gridData.push(item.caseInfo)
  578. })
  579. this.total = this.gridData.length
  580. })
  581. this.implement()
  582. }
  583. },
  584. Unclicked(e, index, ele) {
  585. this.gridData[index].keys = 1
  586. updateTestPlanCase({ creator: this.userInformation, modifier: this.userInformation, id: ele.ids, status: 1, testPlanId: ele.thrr }).then(res => {
  587. if (res.code === 200) {
  588. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  589. } else {
  590. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  591. }
  592. })
  593. },
  594. Unclicked2(e, index, ele) {
  595. this.gridData[index].keys = 2
  596. updateTestPlanCase({ creator: this.userInformation, modifier: this.userInformation, id: ele.ids, status: 2, testPlanId: ele.thrr }).then(res => {
  597. if (res.code === 200) {
  598. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  599. } else {
  600. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  601. }
  602. })
  603. },
  604. Unclicked3(e, index, ele) {
  605. this.gridData[index].keys = 3
  606. updateTestPlanCase({ creator: this.userInformation, modifier: this.userInformation, id: ele.ids, status: 3, testPlanId: ele.thrr }).then(res => {
  607. if (res.code === 200) {
  608. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  609. } else {
  610. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  611. }
  612. })
  613. },
  614. Unclicked4(e, index, ele) {
  615. this.gridData[index].keys = 0
  616. updateTestPlanCase({ creator: this.userInformation, modifier: this.userInformation, id: ele.ids, status: 0, testPlanId: ele.thrr }).then(res => {
  617. if (res.code === 200) {
  618. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  619. } else {
  620. this.$message({ message: res.msg, type: 'error', duration: 1000, offset: 150 })
  621. }
  622. })
  623. },
  624. // 查询接口list
  625. query_get(e) {
  626. var data_status = { testPlanId: e, pageSize: this.pageSize, curIndex: this.curIndex }
  627. queryTestPlanCaseList(data_status).then(res => {
  628. this.gridData = []
  629. res.data.map(item => {
  630. item.caseInfo.ids = item.id
  631. item.caseInfo.status_case = item.status
  632. item.caseInfo.keys = item.status
  633. this.gridData.push(item.caseInfo)
  634. })
  635. this.total = this.gridData.total
  636. })
  637. },
  638. // 跳转bug页面
  639. go_Bug(e) {
  640. this.$router.push({ path: '/Platform/defectManagement/bugCreate', query: { ids: e.ids, testPlanId: e.thrr }})
  641. },
  642. // 跳转查看页面
  643. go_query(e) {
  644. this.$router.push({ path: '/Platform/useCasePage/queryUse', query: { id: e.id }})
  645. },
  646. // 执行结果
  647. implement() {
  648. passRateOfTestPlan({ testPlanId: this.startId }).then(res => {
  649. this.num = {
  650. Count1: res.data.successCount,
  651. Rate1: Math.floor(res.data.successRate * 1000) / 1000,
  652. Count2: res.data.blockCount,
  653. Rate2: Math.floor(res.data.blockRate * 1000) / 1000,
  654. Count3: res.data.failCount,
  655. Rate3: Math.floor(res.data.failRate * 1000) / 1000,
  656. Count4: res.data.defaultCount,
  657. Rate4: Math.floor(res.data.defaultRate * 1000) / 1000
  658. }
  659. })
  660. },
  661. // 删除table信息
  662. deleteCaseData(e) {
  663. this.$confirm('是否确认删除', '确认信息', {
  664. distinguishCancelAndClose: true,
  665. confirmButtonText: '确定',
  666. cancelButtonText: '取消'
  667. }).then(() => {
  668. deleteTestPlanCase({ id: e.ids, modifier: this.userInformation }).then(res => {
  669. if (res.code === 200) {
  670. this.query_get(e.thrr)
  671. this.$message({ type: 'success', message: '已删除' })
  672. } else {
  673. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  674. }
  675. })
  676. }).catch(action => { this.$message({ message: '已取消', type: 'error', duration: 1000, offset: 150 }) })
  677. }
  678. }
  679. }
  680. </script>
  681. <style>
  682. .custom-tree-node {
  683. flex: 1;
  684. display: flex;
  685. align-items: center;
  686. justify-content: space-between;
  687. font-size: 14px;
  688. padding-right: 8px;
  689. }
  690. .nav_Input .el-input--mini .el-input__inner {
  691. height: 23px !important;
  692. }
  693. .nav_Input .el-tree-node__content {
  694. color: #333B4A;
  695. }
  696. .nav_Input .el-tree-node__content .el-tree-node__expand-icon{
  697. color: #333B4A;
  698. }
  699. .nav_Input .el-tree-node__expand-icon.is-leaf{
  700. color: transparent !important;
  701. cursor: default !important
  702. }
  703. .nav_Input .el-tree-node__children .custom-tree-node{
  704. color: #6F7C93;
  705. }
  706. .span_el {
  707. display: block;
  708. overflow: hidden;
  709. text-overflow: ellipsis;
  710. }
  711. .btn_query .el-button--primary.is-plain {
  712. color: #000000 !important;
  713. background: #F9F9FA !important;
  714. border-color: #F9F9FA !important;
  715. }
  716. </style>