123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <view class="content">
- <view class="one">
- <input type="text" v-model="searchInfo.good_name" @input="toInput" placeholder="搜索商品">
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
- <view class="list_1">
- <text>
- <text class="iconfont icon-changshangguanli"></text>
- {{item.supplier_name}}
- </text>
- <text class="status">{{item.zhStatus}}</text>
- </view>
- <view class="list_2">
- <view class="left">
- <image v-if="item.spec_file" class="image"
- :src="item.spec_file&&item.spec_file.length>0?item.spec_file[0].url:''" mode="">
- </image>
- <image v-else class="image"
- :src="item.good_file&&item.good_file.length>0?item.good_file[0].url:''" mode="">
- </image>
- </view>
- <view class="right">
- <view class="right_1">
- <view class="name textOver">
- <text>{{item.good_name||'暂无'}}</text>
- </view>
- </view>
- <view class="right_2">
- <view class="spec textOver">
- <text>规格:</text>
- <text>{{item.spec_name||'暂无'}}</text>
- </view>
- <view class="spec textOver">
- <text>申请时间:</text>
- <text>{{item.apply_time||'暂无'}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="bottom">
- <button v-if="item.status=='0'" size="mini" type="default"
- @tap.stop="toKeep(item,'1')">正在维修</button>
- <button v-if="item.status=='1'" size="mini" type="success"
- @tap.stop="toKeep(item,'2')">维修成功</button>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- user: {},
- searchInfo: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- // 字典表
- statusList: [],
- roleList: []
- }
- },
- onLoad: function(e) {
- const that = this;
- that.searchConfig();
- },
- onShow: async function(e) {
- const that = this;
- await that.searchOther();
- that.searchToken();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- searchConfig() {
- const that = this;
- try {
- const res = uni.getStorageSync('config');
- if (res) that.$set(that, `config`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- that.$set(that, `user`, res);
- that.clearPage();
- that.search();
- }
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- async search() {
- const that = this;
- let user = that.user;
- let info = {
- skip: that.skip,
- limit: that.limit,
- supplier: user._id
- };
- let res;
- res = await that.$api(`/Upkeep`, 'GET', {
- ...info,
- ...that.searchInfo
- });
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- for (let val of list) {
- val.zhStatus = that.searchDict(val.status, 'status')
- }
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- },
- // 查看详情
- toInfo(e) {
- uni.navigateTo({
- url: `/pagesMy/repair/detail?id=${e.id||e._id}`
- })
- },
- // 申请维修
- toKeep(item, type) {
- const that = this;
- let user = that.user;
- let obj = {
- status: type,
- order_id: item.order_id
- }
- uni.showModal({
- title: '提示',
- content: '确定该商品维修成功吗?',
- success: async function(res) {
- if (res.confirm) {
- const res = await that.$api(`/Upkeep/${item._id}`, 'POST', obj);
- if (res.errcode == '0') {
- uni.showToast({
- title: '维护信息成功',
- icon: 'none'
- })
- that.clearPage()
- that.search()
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- }
- });
- },
- // 查询字典表
- searchDict(e, model) {
- const that = this;
- let data
- if (model == 'status') {
- data = that.statusList.find((i) => i.value == e);
- if (data) return data.label
- else return '暂无'
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- // 触底
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (that.searchInfo.good_name) that.$set(that.searchInfo, `good_name`, e.detail.value)
- else that.$set(that, `searchInfo`, {})
- that.clearPage();
- that.search();
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- // 查询状态
- res = await that.$api(`/DictData`, 'GET', {
- type: 'upkeep',
- is_use: '0'
- })
- if (res.errcode == '0') that.$set(that, `statusList`, res.data);
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss">
- .content {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- background-color: var(--f9Color);
- .list {
- background-color: #fff;
- border: 1px solid var(--f5Color);
- padding: 2vw;
- margin: 2vw 2vw 0 2vw;
- border-radius: 5px;
- .list_1 {
- display: flex;
- justify-content: space-between;
- padding: 2vw 0;
- font-size: var(--font16Size);
- .status {
- font-size: var(--font14Size);
- color: var(--fF0Color);
- }
- }
- .list_2 {
- display: flex;
- .left {
- .image {
- width: 20vw;
- height: 20vw;
- border-radius: 5px;
- border: 1px solid var(--f9Color);
- }
- }
- .right {
- width: 70vw;
- margin: 0 0 0 2vw;
- .right_1 {
- display: flex;
- justify-content: space-between;
- margin: 0 0 2vw 0;
- .name {
- font-size: var(--font14Size);
- }
- .num {
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- text:last-child {
- font-size: var(--font13Size);
- color: var(--f85Color);
- }
- }
- }
- .right_2 {
- font-size: var(--font12Size);
- .spec {
- text:first-child {
- color: var(--f85Color);
- }
- }
- }
- }
- }
- .bottom {
- text-align: center;
- padding: 1vw 0;
- button {
- margin: 0 5px 0 0;
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .is_bottom {
- width: 100%;
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- </style>
|