You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

406 lines
12 KiB

3 years ago
  1. <template>
  2. <section class="padding">
  3. <el-row class="padding-bottom">
  4. <span>报告概览</span>
  5. </el-row>
  6. <el-row ref="table">
  7. <el-row class="box">
  8. <el-col :span="6" class="box-red">
  9. <div class="box-info">
  10. <div class="num">{{xmTestPlan.totalCases?xmTestPlan.totalCases:'0'}}</div>
  11. <div class="label">用例数</div>
  12. </div>
  13. </el-col>
  14. <el-col :span="6" class="box-blue">
  15. <div class="box-info">
  16. <div class="num">{{caseFuGaiLv}}%</div>
  17. <div class="label">用例覆盖率</div>
  18. </div>
  19. </el-col>
  20. <el-col :span="6" class="box-green">
  21. <div class="box-info">
  22. <div class="num">{{caseTongGuoLv}}%</div>
  23. <div class="label">用例通过率</div>
  24. </div>
  25. </el-col>
  26. <el-col :span="6" class="box-orange">
  27. <div class="box-info">
  28. <div class="num">{{xmTestPlan.bugCnt?xmTestPlan.bugCnt:0}}</div>
  29. <div class="label">缺陷数</div>
  30. </div>
  31. </el-col>
  32. </el-row>
  33. <!--编辑界面 XmTestPlan 测试计划-->
  34. <el-form :model="rawDatas" label-width="120px" :rules="rawDatasRules" ref="rawDatasRef" label-position="left">
  35. <el-form-item prop="name" label-width="0px">
  36. <el-row class="padding-bottom">
  37. <my-input v-model="rawDatas.name" placeholder="计划名称" :maxlength="255" @change="editSomeFields(rawDatas,'name',$event)"></my-input>
  38. </el-row>
  39. </el-form-item>
  40. <el-row class="padding">
  41. <el-col :span="8">
  42. <mdp-select-user-xm label="负责人" userid-key="cuserid" username-key="cusername" v-model="rawDatas" @change="editSomeFields(rawDatas,'cuserid',$event)"></mdp-select-user-xm>
  43. </el-col>
  44. <el-col :span="8">
  45. <mdp-select-dict-x label="状态" :dict="dicts['testPlanStatus']" v-model="rawDatas.status" @change="editSomeFields(rawDatas,'status',$event)"></mdp-select-dict-x>
  46. </el-col>
  47. <el-col :span="8">
  48. <mdp-select-dict-x label="测试结果" :dict="dicts['testPlanTcode']" v-model="rawDatas.tcode" @change="editSomeFields(rawDatas,'tcode',$event)"></mdp-select-dict-x>
  49. </el-col>
  50. </el-row>
  51. <el-form-item label="归属测试库" prop="casedbName">
  52. {{rawDatas.casedbName}}
  53. </el-form-item>
  54. <el-form-item label="归属项目" prop="projectId">
  55. <span v-if="opType=='add'">
  56. <xm-project-select v-if="!selProject || !selProject.id" ref="xmProjectSelect" :link-product-id="xmTestCasedb? xmTestCasedb.productId:null" @row-click="onPorjectConfirm" :auto-select="false">
  57. <span slot="title">选择项目</span>
  58. </xm-project-select>
  59. <div v-else>{{rawDatas.projectName}}</div>
  60. </span>
  61. <div v-else>{{rawDatas.projectName}}</div>
  62. </el-form-item>
  63. <el-form-item label="归属产品" prop="productName">
  64. {{rawDatas.productName}}
  65. </el-form-item>
  66. <el-form-item label="起止时间" prop="stime">
  67. <mdp-date-range :auto-default="false" placeholder="选择日期" v-model="rawDatas" start-key="stime" end-key="etime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" @change="editSomeFields(rawDatas,'stime',rawDatas)"></mdp-date-range>
  68. </el-form-item>
  69. </el-form>
  70. </el-row>
  71. <el-row class="padding-bottom">
  72. <span>报告总结</span>
  73. </el-row>
  74. <el-row>
  75. <el-input type="textarea" :rows="8" v-model="rawDatas.summaryRemark"></el-input>
  76. </el-row>
  77. <el-row v-if="rawDatas.summaryRemark!==rawDatasBak.summaryRemark" >
  78. <span style="float:right;">
  79. <el-button type="primary" @click.native="editSomeFields(rawDatas,'summaryRemark',rawDatas.summaryRemark)">提交</el-button>
  80. </span>
  81. </el-row>
  82. </section>
  83. </template>
  84. <script>
  85. import util from '@/common/js/util';//全局公共库
  86. import config from "@/common/config"; //全局公共库import
  87. import { initDicts, addXmTestPlan,editXmTestPlan,editSomeFieldsXmTestPlan } from '@/api/xm/core/xmTestPlan';
  88. import { mapGetters } from 'vuex'
  89. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';
  90. import MdpSelectUserXm from '@/views/xm/core/components/MdpSelectUserXm';//修改界面
  91. export default {
  92. name:'xmTestPlanEdit',
  93. components: {
  94. XmProjectSelect,MdpSelectUserXm,
  95. },
  96. computed: {
  97. ...mapGetters([ 'userInfo' ]),
  98. caseFuGaiLv(){
  99. if(!this.xmTestPlan.totalCases){
  100. return 0
  101. }
  102. var okCases=parseInt(this.xmTestPlan.okCases>0?this.xmTestPlan.okCases:0)
  103. var errCases=parseInt(this.xmTestPlan.errCases>0?this.xmTestPlan.errCases:0)
  104. var igCases=parseInt(this.xmTestPlan.igCases>0?this.xmTestPlan.igCases:0)
  105. var blCases=parseInt(this.xmTestPlan.blCases>0?this.xmTestPlan.blCases:0)
  106. var totalExecs=okCases+errCases+igCases+blCases
  107. var rate=parseInt(totalExecs/this.xmTestPlan.totalCases*100)
  108. return rate;
  109. },
  110. caseTongGuoLv(){
  111. if(!this.xmTestPlan.totalCases){
  112. return 0
  113. }
  114. var okCases=parseInt(this.xmTestPlan.okCases>0?this.xmTestPlan.okCases:0)
  115. var errCases=parseInt(this.xmTestPlan.errCases>0?this.xmTestPlan.errCases:0)
  116. var igCases=parseInt(this.xmTestPlan.igCases>0?this.xmTestPlan.igCases:0)
  117. var blCases=parseInt(this.xmTestPlan.blCases>0?this.xmTestPlan.blCases:0)
  118. var totalExecs=okCases+igCases
  119. var rate=parseInt(totalExecs/this.xmTestPlan.totalCases*100)
  120. return rate;
  121. }
  122. },
  123. props:['xmTestPlan','visible','opType','selProject','xmTestCasedb','rptDatas'],
  124. watch: {
  125. 'xmTestPlan':function( xmTestPlan ) {
  126. if(xmTestPlan){
  127. this.rawDatas = {...xmTestPlan};
  128. }
  129. },
  130. 'visible':function(visible) {
  131. if(visible==true){
  132. this.initData()
  133. }
  134. }
  135. },
  136. data() {
  137. return {
  138. currOpType:'add',//add/edit
  139. load:{ list: false, edit: false, del: false, add: false },//查询中...
  140. dicts:{
  141. testPlanStatus:[],
  142. testPlanTcode:[],
  143. },//下拉选择框的所有静态数据 params={categoryId:'all',itemCodes:['sex']} 返回结果 {sex: [{id:'1',name:'男'},{id:'2',name:'女'}]}
  144. rawDatasRules: {
  145. },
  146. rawDatas: {
  147. id:'',name:'',casedbId:'',casedbName:'',projectId:'',projectName:'',cuserid:'',cusername:'',ctime:'',stime:'',etime:'',status:'',tcode:'',totalCases:'',okCases:'',errCases:'',igCases:'',blCases:'',productId:'',productName:'',flowState:'',summaryRemark:''
  148. },
  149. rawDatasBak: {
  150. id:'',name:'',casedbId:'',casedbName:'',projectId:'',projectName:'',cuserid:'',cusername:'',ctime:'',stime:'',etime:'',status:'',tcode:'',totalCases:'',okCases:'',errCases:'',igCases:'',blCases:'',productId:'',productName:'',flowState:'',summaryRemark:''
  151. },
  152. maxTableHeight:300,
  153. summaryRemarkEditVisible:false,
  154. }//end return
  155. },//end data
  156. methods: {
  157. ...util,
  158. // 取消按钮点击 父组件监听@cancel="rawDatasVisible=false" 监听
  159. handleCancel:function(){
  160. this.$refs['rawDatasRef'].resetFields();
  161. this.$emit('cancel');
  162. },
  163. //新增、编辑提交XmTestPlan 测试计划父组件监听@submit="afterEditSubmit"
  164. saveSubmit: function () {
  165. this.$refs.rawDatasRef.validate((valid) => {
  166. if (valid) {
  167. this.$confirm('确认提交吗?', '提示', {}).then(() => {
  168. this.load.edit=true
  169. let params = Object.assign({}, this.rawDatas);
  170. var func=addXmTestPlan
  171. if(this.currOpType=='edit'){
  172. func=editXmTestPlan
  173. }
  174. func(params).then((res) => {
  175. this.load.edit=false
  176. var tips=res.data.tips;
  177. if(tips.isOk){
  178. this.rawDatas=res.data.data
  179. this.initData()
  180. this.currOpType="edit";
  181. this.$emit('submit');// @submit="afterAddSubmit"
  182. }
  183. this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
  184. }).catch( err =>this.load.edit=false);
  185. });
  186. }else{
  187. this.$notify({ showClose:true, message: "表单验证不通过,请修改表单数据再提交", type: 'error' });
  188. }
  189. });
  190. },
  191. initData: function(){
  192. if(this.xmTestPlan){
  193. this.rawDatas = Object.assign({},this.xmTestPlan);
  194. }
  195. if(this.rptDatas){
  196. this.rawDatas=Object.assign({},this.rptDatas)
  197. }
  198. this.rawDatasBak={...this.rawDatas}
  199. },
  200. editSomeFields(row,fieldName,$event){
  201. if(this.opType=='add'){
  202. return;
  203. }
  204. let params={};
  205. params['ids']=[row].map(i=>i.id)
  206. if(fieldName=='stime'){
  207. params[fieldName]=$event.stime
  208. params.etime=$event.etime
  209. }else if(fieldName=='cuserid'){
  210. params[fieldName]=$event[0].userid
  211. params.cusername=$event[0].username
  212. }else{
  213. params[fieldName]=$event
  214. }
  215. var func = editSomeFieldsXmTestPlan
  216. func(params).then(res=>{
  217. let tips = res.data.tips;
  218. if(tips.isOk){
  219. this.rawDatasBak=[...this.rawDatas]
  220. this.$emit('edit-fields',params)
  221. }else{
  222. Object.assign(this.rawDatas,this.rawDatasBak)
  223. this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'})
  224. }
  225. }).catch((e)=>Object.assign(this.rawDatas,this.rawDatasBak))
  226. },
  227. onPorjectConfirm(row){
  228. this.rawDatas.projectId=row.id
  229. this.rawDatas.projectName=row.name
  230. this.rawDatas.name=this.rawDatas.projectName+'-测试计划-V1.0'
  231. },
  232. sizeAutoChange(){
  233. }
  234. },//end method
  235. mounted() {
  236. this.$nextTick(() => {
  237. initDicts(this);
  238. this.initData()
  239. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.table.$el)
  240. });
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .box{
  246. .box-red{
  247. background-color: #ff75750d;
  248. height: 100px;
  249. border-left-width: 2px;
  250. border-left-color: red;
  251. border-left-style: solid;
  252. align-items: center;
  253. line-height: 100px;
  254. text-align: center;
  255. display:flex;
  256. flex-direction: column;
  257. .box-info{
  258. display:flex;
  259. flex-direction: column;
  260. margin-top: 20px;
  261. height: 100px;
  262. line-height: 100px;
  263. .label{
  264. color: #999;
  265. height: 30px;
  266. line-height: 30px;
  267. font-size: 0.875rem;
  268. }
  269. .num{
  270. height: 30px;
  271. line-height: 30px;
  272. color:red ;
  273. font-size: 30px;
  274. }
  275. }
  276. }
  277. .box-green{
  278. background-color: #73d8970d;;
  279. height: 100px;
  280. border-left-width: 2px;
  281. border-left-color: green;
  282. border-left-style: solid;
  283. align-items: center;
  284. line-height: 100px;
  285. text-align: center;
  286. display:flex;
  287. flex-direction: column;
  288. .box-info{
  289. display:flex;
  290. flex-direction: column;
  291. margin-top: 20px;
  292. height: 100px;
  293. line-height: 100px;
  294. .label{
  295. color: #999;
  296. height: 30px;
  297. line-height: 30px;
  298. font-size: 0.875rem;
  299. }
  300. .num{
  301. height: 30px;
  302. line-height: 30px;
  303. color:green ;
  304. font-size: 30px;
  305. }
  306. }
  307. }
  308. .box-blue{
  309. background-color: #5dcfff0d;
  310. height: 100px;
  311. border-left-width: 2px;
  312. border-left-color: blue;
  313. border-left-style: solid;
  314. align-items: center;
  315. line-height: 100px;
  316. text-align: center;
  317. display:flex;
  318. flex-direction: column;
  319. .box-info{
  320. display:flex;
  321. flex-direction: column;
  322. margin-top: 20px;
  323. height: 100px;
  324. line-height: 100px;
  325. .label{
  326. color: #999;
  327. height: 30px;
  328. line-height: 30px;
  329. font-size: 0.875rem;
  330. }
  331. .num{
  332. height: 30px;
  333. line-height: 30px;
  334. color:blue ;
  335. font-size: 30px;
  336. }
  337. }
  338. }
  339. .box-orange{
  340. background-color: #ffcd5d0d;
  341. height: 100px;
  342. border-left-width: 2px;
  343. border-left-color: orange;
  344. border-left-style: solid;
  345. align-items: center;
  346. line-height: 100px;
  347. text-align: center;
  348. display:flex;
  349. flex-direction: column;
  350. .box-info{
  351. display:flex;
  352. flex-direction: column;
  353. margin-top: 20px;
  354. height: 100px;
  355. line-height: 100px;
  356. .label{
  357. color: #999;
  358. height: 30px;
  359. line-height: 30px;
  360. font-size: 0.875rem;
  361. }
  362. .num{
  363. height: 30px;
  364. line-height: 30px;
  365. color:orange ;
  366. font-size: 30px;
  367. }
  368. }
  369. }
  370. box-font{
  371. font-size: 0.875rem;
  372. }
  373. }
  374. </style>