123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <view>
- <view class="body">
- 订单编号:<input class="input" v-model="orderNo" />
- <button type="primary" @click="select(orderNo)" class="" size="mini">
- 搜索
- </button>
- <button type="primary" @click="expert(orderNo)" class="" size="mini">
- 导出
- </button>
- </view>
- <view class="">
- <uni-collapse :accordion="true">
- <uni-list>
- <view v-for="machine in machineList" :key="machine.id">
- <uni-list-item :title="machine.coding" @click="trun(machine.coding)"/>
- </view>
- </uni-list>
- </uni-collapse>
- </view>
-
- </view>
- </template>
- <script>
- import {
- mapState,
- mapActions,
- mapMutations
- } from 'vuex'
- import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
- import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
- import uniList from '@/components/uni-list/uni-list.vue'
- import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
- export default {
- components: {
- uniCollapse,
- uniCollapseItem,
- uniList,
- uniListItem,
- },
- data() {
- return {
- orderNo:'',
- machineList:''
- }
- },
- methods: {
- select(orderNo) {
- var that = this;
- var serverUrl = that.serverurl;
- var token = uni.getStorageSync("token");
- uni.request({
- url: serverUrl + "/TMachine/selectMachineByOrderNo?orderNo=" + orderNo,
- method: "GET",
- header: {
- 'token': token
- },
- success: (Result) => {
- var res = Result;
- if (res.data.code == true) {
- that.machineList = res.data.data;
- } else {
- uni.showModal({
- title: '提示',
- content: res.data.message,
- });
- }
- }
- });
- },
- trun(coding) {
- var item = {
- coding:'',
- type:''
- };
- item.coding = coding;
- uni.navigateTo({
- url:'selectMachine?item='+encodeURIComponent(JSON.stringify(item))
- });
- },
- expert(orderNo) {
- var that = this;
- var serverUrl = that.serverurl;
- var token = uni.getStorageSync("token");
- uni.request({
- url: serverUrl + "/TMachine/expert?orderNo=" + orderNo,
- method: "GET",
- header: {
- 'token': token
- },
- success: (Result) => {
- var res = Result;
- if (res.data.code == true) {
- var url = res.data.data;
- var a= [];
- a=url.split("machine/");
- // a=url.split("excel/");
- var fileName = a[1];
- wx.downloadFile({
- url: url,
- /* 这里指定filePath属性,不然会是一个临时文件,不能用对应的程序打开 */
- filePath:wx.env.USER_DATA_PATH + '/' + fileName,
- success(result) {
- const filePath = result.filePath;
- wx.openDocument({
- filePath: filePath,
- showMenu: true,
- fileType: "xls",
- success: rlt => {
- console.log("打开文档成功",rlt);
- },
- fail: err => {
- wx.showModal({
- content: JSON.stringify(err),
- showCancel: false
- })
- }
- });
- },
- fail(error){
- wx.showModal({
- content: JSON.stringify(error),
- showCancel: false
- })
- }
- })
- } else {
- uni.showModal({
- title: '提示',
- content: res.data.message,
- });
- }
- }
- });
- }
- }
- }
- </script>
- <style>
- .body {
- background-color: #FFFFFF;
- padding: 20upx;
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
-
- }
- .input {
- padding-left: 10upx;
- background-color: #FFFFFF;
- width: 280upx;
- height: 55upx;
- box-shadow: 0upx 0upx 20upx #D3D3D3;
- border-radius: 5upx;
- }
- </style>
|