index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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.total_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 = '7';
  133. info.accounting = user._id;
  134. } else if (user.role == 'ld') {
  135. info.status = '8';
  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. async toExam(item, type) {
  172. const that = this;
  173. let user = that.user;
  174. let obj = {}
  175. if (type == '0') {
  176. if (user.role == 'kj') obj.status = '8';
  177. else obj.status = '9';
  178. } else {
  179. if (user.role == 'kj') obj.status = '-9';
  180. else obj.status = '-9';
  181. }
  182. uni.showModal({
  183. title: '提示',
  184. content: '确定审核该订单吗?',
  185. success: async function(res) {
  186. if (res.confirm) {
  187. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  188. if (res.errcode == '0') {
  189. uni.showToast({
  190. title: '维护信息成功',
  191. icon: 'none'
  192. })
  193. that.clearPage()
  194. that.search()
  195. } else {
  196. uni.showToast({
  197. title: res.errmsg,
  198. icon: 'none'
  199. })
  200. }
  201. }
  202. }
  203. });
  204. },
  205. // 分页
  206. toPage(e) {
  207. const that = this;
  208. let list = that.list;
  209. let limit = that.limit;
  210. if (that.total > list.length) {
  211. uni.showLoading({
  212. title: '加载中',
  213. mask: true
  214. })
  215. let page = that.page + 1;
  216. that.$set(that, `page`, page)
  217. let skip = page * limit;
  218. that.$set(that, `skip`, skip)
  219. that.search();
  220. uni.hideLoading();
  221. } else that.$set(that, `is_bottom`, true)
  222. },
  223. // 触底
  224. toScroll(e) {
  225. const that = this;
  226. let up = that.scrollTop;
  227. that.$set(that, `scrollTop`, e.detail.scrollTop);
  228. let num = Math.sign(up - e.detail.scrollTop);
  229. if (num == 1) that.$set(that, `is_bottom`, false);
  230. },
  231. // 输入框
  232. toInput(e) {
  233. const that = this;
  234. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  235. else that.$set(that, `searchInfo`, {})
  236. that.clearPage();
  237. that.search();
  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. is_use: '0',
  247. })
  248. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  249. },
  250. // 清空列表
  251. clearPage() {
  252. const that = this;
  253. that.$set(that, `list`, [])
  254. that.$set(that, `skip`, 0)
  255. that.$set(that, `limit`, 6)
  256. that.$set(that, `page`, 0)
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .content {
  263. display: flex;
  264. flex-direction: column;
  265. width: 100vw;
  266. height: 100vh;
  267. .one {
  268. padding: 2vw;
  269. input {
  270. padding: 2vw;
  271. background-color: var(--f1Color);
  272. font-size: var(--font14Size);
  273. border-radius: 5px;
  274. }
  275. }
  276. .two {
  277. position: relative;
  278. flex-grow: 1;
  279. background-color: var(--f9Color);
  280. .list {
  281. background-color: #fff;
  282. border: 1px solid var(--f5Color);
  283. padding: 2vw;
  284. margin: 2vw 2vw 0 2vw;
  285. border-radius: 5px;
  286. .list_1 {
  287. display: flex;
  288. justify-content: space-between;
  289. padding: 2vw 0;
  290. font-size: var(--font16Size);
  291. .status {
  292. font-size: var(--font14Size);
  293. color: var(--fF0Color);
  294. }
  295. }
  296. .list_2 {
  297. display: flex;
  298. .left {
  299. .image {
  300. width: 20vw;
  301. height: 20vw;
  302. border-radius: 5px;
  303. }
  304. }
  305. .right {
  306. width: 70vw;
  307. margin: 0 0 0 2vw;
  308. .right_1 {
  309. display: flex;
  310. justify-content: space-between;
  311. margin: 2vw 0;
  312. .name {
  313. font-size: var(--font14Size);
  314. }
  315. .num {
  316. display: flex;
  317. flex-direction: column;
  318. align-items: flex-end;
  319. text:last-child {
  320. font-size: var(--font13Size);
  321. color: var(--f85Color);
  322. }
  323. }
  324. }
  325. .right_2 {
  326. font-size: var(--font12Size);
  327. color: var(--f85Color);
  328. }
  329. }
  330. }
  331. .bottom {
  332. text-align: center;
  333. padding: 1vw 0;
  334. button {
  335. margin: 0 5px 0 0;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. .scroll-view {
  342. position: absolute;
  343. top: 0;
  344. left: 0;
  345. right: 0;
  346. bottom: 0;
  347. .list-scroll-view {
  348. display: flex;
  349. flex-direction: column;
  350. }
  351. }
  352. .is_bottom {
  353. text-align: center;
  354. text {
  355. padding: 2vw 0;
  356. display: inline-block;
  357. color: var(--f85Color);
  358. font-size: var(--font14Size);
  359. }
  360. }
  361. </style>