SelectRelationContract.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <uni-forms ref="form" @submit="submitForm">
  4. <uni-list>
  5. <radio-group @change="radioChange">
  6. <uni-list-item v-for="(item,index) in contractList" :key="index">
  7. <!-- 自定义 header -->
  8. <view slot="header" class="slot-box-header">
  9. <radio :value="item.contractCode" />
  10. </view>
  11. <!-- 自定义 body -->
  12. <view slot="body" class="slot-box-body">
  13. {{item.contractName}}
  14. </view>
  15. <!-- 自定义 footer-->
  16. <view slot="footer" class="slot-box-footer">
  17. {{item.contractDate}}
  18. </view>
  19. </uni-list-item>
  20. </radio-group>
  21. </uni-list>
  22. <view class="uni-btn-v uni-column">
  23. <button type="primary" form-type="submit" style="border-radius: 15px;">选择成功,确认</button>
  24. </view>
  25. </uni-forms>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. GetRelationRequistionContract
  31. } from "@/common/api/requisitionApi.js";
  32. export default {
  33. data() {
  34. return {
  35. contractList: [],
  36. radioValue: [],
  37. searchVal: ''
  38. }
  39. },
  40. onLoad: function() {
  41. //console.info('授权');
  42. //console.info(this.$auth);
  43. this.$util.persistLogin(this);
  44. },
  45. created: function() {
  46. this.getcontractList();
  47. },
  48. methods: {
  49. getcontractList: function() {
  50. var that = this;
  51. let projectcode = this.$store.state.projectCode;
  52. let requisitionCode=this.$util.getQuery("requisitionCode");
  53. uni.showLoading({
  54. title: "页面努力加载中,请稍候...",
  55. mask: true
  56. });
  57. GetRelationRequistionContract(projectcode, requisitionCode).then((res) => {
  58. uni.hideLoading();
  59. console.info('GetRelationRequistionContract', res);
  60. //console.info(projectCode);
  61. //console.info(res);
  62. //return;
  63. res.forEach(function(item, index, array) {
  64. item.contractDate=item.contractDate.substring(0,10);
  65. that.$set(that.contractList, index, item);
  66. });
  67. //console.info(that.contractList);
  68. });
  69. },
  70. radioChange: function(evt) {
  71. //console.info(evt);
  72. //console.info(evt.target.value);
  73. //console.info('contractList',this.contractList);
  74. for (let i = 0; i < this.contractList.length; i++) {
  75. if (this.contractList[i].contractCode === evt.target.value) {
  76. console.info(evt.target.value);
  77. this.current = i;
  78. this.radioValue = this.contractList[i];
  79. console.info('this.radioValue', this.radioValue);
  80. break;
  81. }
  82. }
  83. },
  84. submitForm(e) {
  85. console.info('submitForm',this.radioValue);
  86. //return;
  87. //先记录值,下面this指向会不一样
  88. let relationContractCodes = this.radioValue;
  89. if (relationContractCodes.length<=0) {
  90. uni.showToast({
  91. title: '请选择申请单',
  92. duration: 3000,
  93. icon: 'none'
  94. })
  95. return;
  96. }
  97. let selectChecked = [];
  98. selectChecked.push({
  99. contractCode: relationContractCodes.contractCode,
  100. contractName: relationContractCodes.contractName,
  101. contract:relationContractCodes
  102. });
  103. console.info('selectChecked',selectChecked);
  104. //return;
  105. //将数据发射到父级监听事件中
  106. uni.$emit('contract', selectChecked);
  107. //关闭当前窗口
  108. uni.navigateBack({});
  109. },
  110. }
  111. }
  112. </script>
  113. <style scoped>
  114. .slot-box-header {
  115. margin: 5px 5px;
  116. width: 40px;
  117. }
  118. .slot-box-body {
  119. margin: 5px 5px;
  120. width: 240px;
  121. }
  122. .slot-box-footer {
  123. margin: 5px 5px;
  124. width: 120px;
  125. }
  126. .uni-btn-v {
  127. position: fixed;
  128. bottom: 0;
  129. width: 100%;
  130. }
  131. uni-view {
  132. font-size: 15px;
  133. }
  134. </style>