SelectRelationRequision.vue 3.8 KB

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