123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view>
- <view>
- <uni-search-bar :radius="100" @confirm="search" @input="input" @cancel="cancel"></uni-search-bar>
- </view>
- <uni-forms ref="form" @submit="submitForm">
- <uni-list>
- <radio-group @change="radioChange">
- <uni-list-item v-for="(item,index) in contractList" :key="index">
- <!-- 自定义 header -->
- <view slot="header" class="slot-box-header">
- <radio :value="item.contractCode" />
- </view>
- <!-- 自定义 body -->
- <view slot="body" class="slot-box-body">
- {{item.contractID}}
- </view>
- <!-- 自定义 footer-->
- <view slot="footer" class="slot-box-footer">
- {{item.contractName}}
- </view>
- </uni-list-item>
- </radio-group>
- </uni-list>
- <view class="uni-btn-v uni-column">
- <button type="primary" form-type="submit" style="border-radius: 15px;">选择成功,确认</button>
- </view>
- </uni-forms>
- </view>
- </template>
- <script>
- import {
- GetEngineeringContracts
- } from "@/common/api/commonApi.js";
- export default {
- data() {
- return {
- contractList: [],
- radioValue: [],
- searchVal: ''
- }
- },
- onLoad: function() {
- //console.info('授权');
- //console.info(this.$auth);
- this.$util.persistLogin(this);
- },
- created: function() {
- this.getcontractList();
- },
- methods: {
- getcontractList: function() {
- var that = this;
- let projectcode = this.$util.getState(this,'projectCode');
- let searchValue = this.searchVal;
- uni.showLoading({
- title: "页面努力加载中,请稍候...",
- mask: true
- });
- GetEngineeringContracts(projectcode, searchValue).then((res) => {
- uni.hideLoading();
- console.info('GetEngineeringContracts', res);
- //console.info(projectCode);
- //console.info(res);
- //return;
- res.forEach(function(item, index, array) {
- that.$set(that.contractList, index, item);
- });
- //console.info(that.contractList);
- });
- },
- radioChange: function(evt) {
- //console.info(evt);
- //console.info(evt.target.value);
- //console.info('contractList',this.contractList);
- for (let i = 0; i < this.contractList.length; i++) {
- if (this.contractList[i].contractCode === evt.target.value) {
- console.info(evt.target.value);
- this.current = i;
- this.radioValue = this.contractList[i];
- console.info('this.radioValue', this.radioValue);
- break;
- }
- }
- },
- submitForm(e) {
- console.info('submitForm',this.radioValue);
- //先记录值,下面this指向会不一样
- let relationContractCodes = this.radioValue;
- if (relationContractCodes.length<=0) {
- uni.showToast({
- title: '请选择合同',
- duration: 3000,
- icon: 'none'
- })
- return;
- }
-
- let selectChecked = [];
- selectChecked.push({
- contractCode: relationContractCodes.contractCode,
- contractID: relationContractCodes.contractID,
- contractName: relationContractCodes.contractName,
- supplierCode:relationContractCodes.supplierCode,
- supplierTypeCode:relationContractCodes.supplierTypeCode,
- supplierTypeId:relationContractCodes.supplierTypeId
- });
- console.info('selectChecked',selectChecked);
- //return;
- //将数据发射到父级监听事件中
- uni.$emit('engineeringContract', selectChecked);
- //关闭当前窗口
- uni.navigateBack();
- },
- search(res) { //回车搜索
- this.searchvalue = res.value; //赋值
- this.contractList = [];
- this.getcontractList(); //调用搜索方法
- },
- input(res) {
- this.searchVal = res.value
- },
- cancel(res) {
- console.info('点击取消,输入值为:' + res.value);
- }
- }
- }
- </script>
- <style scoped>
- .slot-box-header {
- margin: 5px 5px;
- width: 40px;
- }
- .slot-box-body {
- margin: 5px 5px;
- width: 180px;
- }
- .slot-box-footer {
- margin: 5px 5px;
- width: 180px;
- }
- .uni-btn-v {
- position: fixed;
- bottom: 0;
- width: 100%;
- }
- uni-view {
- font-size: 15px;
- }
- </style>
|