testPage.vue 30 KB

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