index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.goods" @input="toInput" placeholder="搜索商品">
  5. </view>
  6. <view class="two">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  10. <view class="list_1">
  11. <text>
  12. <text class="iconfont icon-changshangguanli"></text>
  13. {{item.supplier_name}}
  14. </text>
  15. <text class="status">{{item.zhStatus}}</text>
  16. </view>
  17. <view class="list_2">
  18. <view class="left">
  19. <image v-if="item.spec_file" class="image" :src="item.spec_file?item.spec_file.url:''"
  20. mode="">
  21. </image>
  22. <image v-else class="image" :src="item.good_file?item.good_file.url:''" mode="">
  23. </image>
  24. </view>
  25. <view class="right">
  26. <view class="right_1">
  27. <view class="name textOver">
  28. <text>{{item.good_name||'暂无'}}</text>
  29. </view>
  30. <view class="num">
  31. <text>¥{{item.money||'0'}}</text>
  32. <text>×{{item.num||'0'}}</text>
  33. </view>
  34. </view>
  35. <view class="right_2">
  36. <view class="spec textOver">
  37. <text>规格:{{item.spec_name||'暂无'}}</text>
  38. </view>
  39. <view class="spec textOver">
  40. <text>购买用户:{{item.user_name||'暂无'}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="bottom">
  46. <button size="mini" type="default" @tap.stop="toExam(item,'0')">审核通过</button>
  47. <button size="mini" type="warn" @tap.stop="toExam(item,'1')">审核拒绝</button>
  48. </view>
  49. </view>
  50. <view class="is_bottom" v-if="is_bottom">
  51. <text>{{config.bottom_title}}</text>
  52. </view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. // 系统设置
  63. config: {},
  64. user: {},
  65. searchInfo: {},
  66. list: [],
  67. total: 0,
  68. skip: 0,
  69. limit: 6,
  70. page: 0,
  71. // 数据是否触底
  72. is_bottom: false,
  73. scrollTop: 0,
  74. // 字典表
  75. statusList: [],
  76. }
  77. },
  78. onLoad: function(e) {
  79. const that = this;
  80. that.searchConfig();
  81. },
  82. onShow: async function(e) {
  83. const that = this;
  84. await that.searchOther();
  85. that.searchToken();
  86. },
  87. onPullDownRefresh: async function() {
  88. const that = this;
  89. that.clearPage();
  90. await that.search();
  91. uni.stopPullDownRefresh();
  92. },
  93. methods: {
  94. searchConfig() {
  95. const that = this;
  96. try {
  97. const res = uni.getStorageSync('config');
  98. if (res) that.$set(that, `config`, res);
  99. } catch (e) {
  100. uni.showToast({
  101. title: err.errmsg,
  102. icon: 'error',
  103. duration: 2000
  104. });
  105. }
  106. },
  107. searchToken() {
  108. const that = this;
  109. try {
  110. const res = uni.getStorageSync('token');
  111. if (res) {
  112. that.$set(that, `user`, res);
  113. that.clearPage();
  114. that.search();
  115. }
  116. } catch (e) {
  117. uni.showToast({
  118. title: err.errmsg,
  119. icon: 'error',
  120. duration: 2000
  121. });
  122. }
  123. },
  124. async search() {
  125. const that = this;
  126. let user = that.user;
  127. let info = {
  128. skip: that.skip,
  129. limit: that.limit,
  130. };
  131. if (user.role == 'kj') {
  132. info.status = '0';
  133. info.accounting = user._id;
  134. } else {
  135. info.status = '2';
  136. info.leader = user._id;
  137. }
  138. let res;
  139. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  140. ...info,
  141. ...that.searchInfo
  142. });
  143. if (res.errcode == '0') {
  144. let list = [...that.list, ...res.data];
  145. for (let val of list) {
  146. val.zhStatus = that.searchStatus(val.status)
  147. }
  148. that.$set(that, `list`, list);
  149. that.$set(that, `total`, res.total)
  150. } else {
  151. uni.showToast({
  152. title: res.errmsg,
  153. icon: 'none'
  154. })
  155. }
  156. },
  157. // 查看详情
  158. toInfo(e) {
  159. uni.navigateTo({
  160. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  161. })
  162. },
  163. // 查询状态
  164. searchStatus(e) {
  165. const that = this;
  166. let data = that.statusList.find((i) => i.value == e);
  167. if (data) return data.label
  168. else return '暂无'
  169. },
  170. // 分页
  171. toPage(e) {
  172. const that = this;
  173. let list = that.list;
  174. let limit = that.limit;
  175. if (that.total > list.length) {
  176. uni.showLoading({
  177. title: '加载中',
  178. mask: true
  179. })
  180. let page = that.page + 1;
  181. that.$set(that, `page`, page)
  182. let skip = page * limit;
  183. that.$set(that, `skip`, skip)
  184. that.search();
  185. uni.hideLoading();
  186. } else that.$set(that, `is_bottom`, true)
  187. },
  188. // 触底
  189. toScroll(e) {
  190. const that = this;
  191. let up = that.scrollTop;
  192. that.$set(that, `scrollTop`, e.detail.scrollTop);
  193. let num = Math.sign(up - e.detail.scrollTop);
  194. if (num == 1) that.$set(that, `is_bottom`, false);
  195. },
  196. // 输入框
  197. toInput(e) {
  198. const that = this;
  199. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  200. else that.$set(that, `searchInfo`, {})
  201. that.clearPage();
  202. that.search();
  203. },
  204. // 审核
  205. async toExam(item, type) {
  206. const that = this;
  207. let user = that.user;
  208. let obj = {};
  209. if (type == '0') {
  210. if (user.role == 'kj') obj.status = '2';
  211. else obj.status = '4';
  212. } else {
  213. if (user.role == 'kj') obj.status = '-2';
  214. else obj.status = '-3';
  215. }
  216. uni.showModal({
  217. title: '提示',
  218. content: '确定审核该订单吗?',
  219. success: async function(res) {
  220. if (res.confirm) {
  221. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  222. if (res.errcode == '0') {
  223. uni.showToast({
  224. title: '维护信息成功',
  225. icon: 'none'
  226. })
  227. that.clearPage()
  228. that.search()
  229. } else {
  230. uni.showToast({
  231. title: res.errmsg,
  232. icon: 'none'
  233. })
  234. }
  235. }
  236. }
  237. });
  238. },
  239. // 查询其他信息
  240. async searchOther() {
  241. const that = this;
  242. let res;
  243. // 查询状态
  244. res = await that.$api(`/DictData`, 'GET', {
  245. type: 'order_status'
  246. })
  247. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  248. },
  249. // 清空列表
  250. clearPage() {
  251. const that = this;
  252. that.$set(that, `list`, [])
  253. that.$set(that, `skip`, 0)
  254. that.$set(that, `limit`, 6)
  255. that.$set(that, `page`, 0)
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss">
  261. .content {
  262. display: flex;
  263. flex-direction: column;
  264. width: 100vw;
  265. height: 100vh;
  266. .one {
  267. padding: 2vw;
  268. input {
  269. padding: 2vw;
  270. background-color: var(--f1Color);
  271. font-size: var(--font14Size);
  272. border-radius: 5px;
  273. }
  274. }
  275. .two {
  276. position: relative;
  277. flex-grow: 1;
  278. background-color: var(--f9Color);
  279. .list {
  280. background-color: #fff;
  281. border: 1px solid var(--f5Color);
  282. padding: 2vw;
  283. margin: 2vw 2vw 0 2vw;
  284. border-radius: 5px;
  285. .list_1 {
  286. display: flex;
  287. justify-content: space-between;
  288. padding: 2vw 0;
  289. font-size: var(--font16Size);
  290. .status {
  291. font-size: var(--font14Size);
  292. color: var(--fF0Color);
  293. }
  294. }
  295. .list_2 {
  296. display: flex;
  297. .left {
  298. .image {
  299. width: 20vw;
  300. height: 20vw;
  301. border-radius: 5px;
  302. }
  303. }
  304. .right {
  305. width: 70vw;
  306. margin: 0 0 0 2vw;
  307. .right_1 {
  308. display: flex;
  309. justify-content: space-between;
  310. margin: 2vw 0;
  311. .name {
  312. font-size: var(--font14Size);
  313. }
  314. .num {
  315. display: flex;
  316. flex-direction: column;
  317. align-items: flex-end;
  318. text:last-child {
  319. font-size: var(--font13Size);
  320. color: var(--f85Color);
  321. }
  322. }
  323. }
  324. .right_2 {
  325. font-size: var(--font12Size);
  326. color: var(--f85Color);
  327. }
  328. }
  329. }
  330. .bottom {
  331. text-align: center;
  332. padding: 1vw 0;
  333. button {
  334. margin: 0 5px 0 0;
  335. }
  336. }
  337. }
  338. }
  339. }
  340. .scroll-view {
  341. position: absolute;
  342. top: 0;
  343. left: 0;
  344. right: 0;
  345. bottom: 0;
  346. .list-scroll-view {
  347. display: flex;
  348. flex-direction: column;
  349. }
  350. }
  351. .is_bottom {
  352. text-align: center;
  353. text {
  354. padding: 2vw 0;
  355. display: inline-block;
  356. color: var(--f85Color);
  357. font-size: var(--font14Size);
  358. }
  359. }
  360. </style>