testToPlanUsecase.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <!-- 关联用例库-->
  3. <div>
  4. <el-dialog
  5. :title="dialogTitlePlanUsecase"
  6. :visible.sync="dialogVisiblePlanUsecase"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. @open="dlgOpen"
  10. @close="dlgClose"
  11. width="90%"
  12. top="20px"
  13. >
  14. <div>
  15. <el-row class="handle-box" style="margin-bottom: 10px">
  16. <el-col :span="16">
  17. <el-select
  18. v-model="search.usecaseType"
  19. size="small"
  20. filterable
  21. clearable
  22. placeholder="用例类型"
  23. @change="handleSearch"
  24. >
  25. <!-- <el-option label="功能测试" value="功能测试"></el-option>-->
  26. <!-- <el-option label="性能测试" value="性能测试"></el-option>-->
  27. <!-- <el-option label="兼容测试" value="兼容测试"></el-option>-->
  28. <el-option
  29. v-for="item in dc_data.TEST_USECASE_TYPE"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. />
  34. </el-select>
  35. <el-input
  36. v-model="search.createdByName"
  37. size="small"
  38. placeholder="创建人"
  39. class="ch-input ch-input-size"
  40. @keyup.enter.native="handleSearch()"
  41. />
  42. <el-select
  43. v-model="search.priority"
  44. size="small"
  45. filterable
  46. clearable
  47. placeholder="请选择优先级"
  48. @change="handleSearch"
  49. >
  50. <!-- <el-option label="P0" value="P0"></el-option>-->
  51. <!-- <el-option label="P1" value="P1"></el-option>-->
  52. <!-- <el-option label="P2" value="P2"></el-option>-->
  53. <el-option
  54. v-for="item in dc_data.TEST_USECASE_PRIORITY"
  55. :key="item.value"
  56. :label="item.label"
  57. :value="item.value"
  58. />
  59. </el-select>
  60. </el-col>
  61. <el-col :span="3" offset="5">
  62. <el-button size="small" class="ch-button-warning" @click="handleReset()"><i
  63. class="el-icon-aim"
  64. />&nbsp;重置
  65. </el-button>
  66. <el-button size="small" class="ch-button" @click="handleSearch()"><i class="el-icon-search"/>&nbsp;搜索
  67. </el-button>
  68. </el-col>
  69. </el-row>
  70. <!-- <button @click="test()">test</button>-->
  71. <p> &nbsp;&nbsp;&nbsp;&nbsp;选中数量 : {{ idList.length }}</p>
  72. <el-row class="handle-box">
  73. <el-col :span="24">
  74. <el-table
  75. ref="multipleTable"
  76. v-loading="loading"
  77. :data="AllData"
  78. stripe
  79. border
  80. row-class-name="g_table_row"
  81. @selection-change="handleSelectionChange"
  82. >
  83. <!-- @sort-change="sortChange"-->
  84. <el-table-column
  85. type="selection"
  86. width="55"
  87. />
  88. <el-table-column label="ID" prop="idPro" width="50"/>
  89. <!-- <el-table-column label="项目名称" prop="projectName"/>-->
  90. <el-table-column label="用例标题" prop="usecaseTitle"/>
  91. <el-table-column label="优先级" prop="priority"/>
  92. <el-table-column label="创建人" prop="createdByName"/>
  93. <el-table-column label="创建时间" prop="createdAt"/>
  94. <el-table-column label="用例类型" prop="usecaseType"/>
  95. </el-table>
  96. <div class="table-page">
  97. <el-pagination
  98. :current-page.sync="currentPage"
  99. :page-size="pageSize"
  100. :page-sizes="[5, 8, 10, 12, 15]"
  101. background
  102. layout="sizes, total, prev, pager, next"
  103. :total="allpage"
  104. @size-change="handleSizeChange"
  105. @current-change="handleCurrentChange"
  106. />
  107. </div>
  108. </el-col>
  109. </el-row>
  110. </div>
  111. <div slot="footer">
  112. <el-button @click="dialogVisiblePlanUsecase = false">取 消</el-button>
  113. <el-button type="primary" @click="confirmSubmit()">保 存</el-button>
  114. </div>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script>
  119. import Base from '../base/base'
  120. export default {
  121. name: 'TestToPlanUsecase',
  122. components: {},
  123. mixins: [Base],
  124. data() {
  125. return {
  126. children: 'this is children',
  127. // 主界面交互字段是否进行了保存
  128. isPlanUsecaseSave: false,
  129. // 查询的时候用的字典========================================
  130. dc_key: ['TEST_USECASE_TYPE', 'TEST_USECASE_PRIORITY'],
  131. search: {
  132. priority: '',
  133. createdByName: '',
  134. usecaseType: ''
  135. // associatedProjectId: ''
  136. },
  137. // ========================================================
  138. // 列表相关=================================================
  139. // 列表中的内容
  140. AllData: [],
  141. // 加载中
  142. loading: false,
  143. // 选中事件的id列表
  144. idList: [],
  145. pageSize: 10,
  146. // 数据页,就是当前页已经改成第二页了,但是数据对应的页码还是第一页就会有问题,所以单独设置出来
  147. datacurrentPage: 1,
  148. // 判断是不是自己主动进行的选择操作,这样可以跳过触发handleSelectionChange事件的问题
  149. isMyselSelect: false,
  150. // =====================================================
  151. // 本页面弹框信息
  152. id: '',
  153. dialogVisiblePlanUsecase: false,
  154. dialogTitlePlanUsecase: ''
  155. // ===================================
  156. }
  157. },
  158. mounted() {
  159. // const _this = this
  160. // this.initDict(_this.dc_key).then((res) => {
  161. // console.log('0')
  162. // // 获取列表数据
  163. // _this.getData()
  164. // })
  165. },
  166. methods: {
  167. dlgOpen() {
  168. const _this = this
  169. this.initDict(_this.dc_key).then((res) => {
  170. // console.log('0')
  171. // 获取列表数据
  172. _this.getData()
  173. _this.isPlanUsecaseSave = false
  174. })
  175. },
  176. dlgClose() {
  177. // console.log('close')
  178. // const _this = this
  179. this.idList = []
  180. },
  181. test() {
  182. console.log(1)
  183. console.log(this.AllData)
  184. this.$refs.multipleTable.toggleRowSelection(this.AllData[0])
  185. },
  186. // zt自己建的进入该界面的初始化方法
  187. initData(dialogTitlePlanUsecase, row) {
  188. const _this = this
  189. _this.dialogTitlePlanUsecase = dialogTitlePlanUsecase
  190. _this.dialogVisiblePlanUsecase = true
  191. // console.log(row)
  192. },
  193. getData: function() {
  194. const _this = this
  195. // console.log(_this.currentPage)
  196. _this.loading = true
  197. _this.AllData = []
  198. _this.search.pageNum = _this.currentPage
  199. // console.log(_this.currentPage)
  200. _this.search.pageSize = _this.pageSize
  201. this.baseRequest('listVo', _this.search).then((res) => {
  202. if (res.data.rows) {
  203. res.data.rows.forEach(function(item) {
  204. const json = _this.getItemJson(item)
  205. _this.AllData.push(json)
  206. })
  207. _this.allpage = res.data.total
  208. _this.datacurrentPage = _this.currentPage
  209. // 对分页进行判断是否已经选择了分页中的数据
  210. // eslint-disable-next-line no-lone-blocks
  211. {
  212. if (this.idList.length === 0) {
  213. // console.consolelog('no info')
  214. } else {
  215. for (let i = 0; i < _this.idList.length; i++) {
  216. // console.log('000...' + _this.idList[i])
  217. if (_this.idList[i].indexOf('@#' + _this.currentPage + '#@') !== -1) {
  218. // console.log('111...' + _this.idList[i])
  219. for (let j = 0; j < _this.AllData.length; j++) {
  220. // console.log('222...' + _this.idList[i])
  221. if (_this.AllData[j].id === _this.idList[i].substring(0, _this.idList[i].indexOf('@#' + _this.currentPage + '#@'))) {
  222. // console.log('333...' + _this.idList[i])
  223. // 这个操作会触发handleSelectionChange的事件,导致有问题,会将别的选项删除
  224. _this.isMyselSelect = true
  225. _this.$refs.multipleTable.toggleRowSelection(_this.AllData[j])
  226. }
  227. }
  228. }
  229. }
  230. _this.isMyselSelect = false
  231. // console.log('has info')
  232. }
  233. }
  234. }
  235. _this.loading = false
  236. }).catch(() => {
  237. })
  238. // this.initOutData()
  239. },
  240. handleSearch: function() {
  241. this.getData()
  242. },
  243. handleReset: function() {
  244. this.submitTime = []
  245. for (const i in this.search) {
  246. if (i !== 'pageNum' && i !== 'pageSize') {
  247. this.search[i] = ''
  248. }
  249. }
  250. this.handleSearch()
  251. },
  252. // 选中事件
  253. handleSelectionChange(val) {
  254. // console.log('自动操作,当前页数:' + this.currentPage + '===' + this.datacurrentPage)
  255. if (this.isMyselSelect) {
  256. return
  257. }
  258. if (this.datacurrentPage !== this.currentPage) {
  259. return
  260. }
  261. if (this.idList.length === 0) {
  262. // console.consolelog('no info')
  263. } else {
  264. for (let i = 0; i < this.idList.length; i++) {
  265. if (this.idList[i].indexOf('@#' + this.currentPage + '#@') != -1) {
  266. this.idList.splice(i, 1)
  267. i--
  268. }
  269. }
  270. // console.log('has info')
  271. }
  272. val.forEach(element => {
  273. this.idList.push(element.id + '@#' + this.currentPage + '#@')
  274. })
  275. // console.log(this.idList)
  276. },
  277. getItemJson: function(item) {
  278. // const json = {
  279. // createdAt: item.createdAt ? this.$common.transDate(item.createdAt,this.$constant.DATE_PATTERN.DATE_TIME_h) : ''
  280. // }
  281. // return json
  282. item.createdAt = item.createdAt ? this.$common.transDate(item.createdAt, this.$constant.DATE_PATTERN.DATE_TIME_h) : ''
  283. return item
  284. },
  285. // 保存/编辑数据
  286. confirmSubmit: function() {
  287. const _this = this
  288. _this.$confirm('确认是否保存关联用例?', '提示', {
  289. confirmButtonText: '确定',
  290. cancelButtonText: '取消',
  291. type: 'warning'
  292. }).then(() => {
  293. // _this.opRecordSavePlanUsecase(null, null)
  294. console.log('进行保存....')
  295. _this.isPlanUsecaseSave = true
  296. _this.dialogVisiblePlanUsecase = false
  297. // this.$emit('passfunction', _this.children)
  298. this.$emit('childEvent',_this.isPlanUsecaseSave)
  299. console.log('end')
  300. }).catch(() => {
  301. _this.$message({
  302. type: 'info',
  303. message: '已取消保存'
  304. })
  305. })
  306. },
  307. opRecordSavePlanUsecase: function(postData, soaUrl, isRefresh) {
  308. // console.log('postData/soaUrl/isRefresh', postData, soaUrl, isRefresh)
  309. if (isRefresh === undefined) {
  310. isRefresh = true
  311. }
  312. const _this = this
  313. const acting = this.$notify({
  314. title: '正在处理,请稍等',
  315. type: 'warning'
  316. })
  317. return this.baseRequest(soaUrl, postData).then((res) => {
  318. acting.close()
  319. if (isRefresh) {
  320. _this.$notify({
  321. title: '处理成功',
  322. type: 'info'
  323. })
  324. }
  325. }).catch((err) => {
  326. acting.close()
  327. _this.$alert(err)
  328. })
  329. },
  330. /* 分页设定*/
  331. handleSizeChange: function(val) {
  332. this.pageSize = val
  333. this.getData()
  334. },
  335. /* 分页设定*/
  336. handleCurrentChange: function(val) {
  337. this.currentPage = val
  338. this.getData()
  339. },
  340. baseRequest(opUrl, postData) {
  341. return this.$channel.globleRequest('TestUsecaseController', opUrl, postData, 'project')
  342. }
  343. }
  344. }
  345. </script>
  346. <style scoped>
  347. .ch-input .el-input__inner {
  348. border-radius: 0px;
  349. border-color: #32323A;
  350. }
  351. .ch-input-size {
  352. width: 150px;
  353. }
  354. .ch-button {
  355. border-radius: 0px;
  356. border-color: #32323A;
  357. background-color: #32323A;
  358. color: #fff;
  359. }
  360. .ch-button-warning {
  361. margin-left: 10px;
  362. border-radius: 0px;
  363. border-color: #E6A23C;
  364. background-color: #E6A23C;
  365. color: #fff;
  366. }
  367. .ch-button-export {
  368. margin-left: 10px;
  369. border-radius: 0px;
  370. border-color: #98CC1F;
  371. background-color: #98CC1F;
  372. color: #fff;
  373. }
  374. </style>