index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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.search();
  114. }
  115. } catch (e) {
  116. uni.showToast({
  117. title: err.errmsg,
  118. icon: 'error',
  119. duration: 2000
  120. });
  121. }
  122. },
  123. async search() {
  124. const that = this;
  125. let user = that.user;
  126. let info = {
  127. skip: that.skip,
  128. limit: that.limit,
  129. };
  130. if (user.role == 'kj') {
  131. info.status = '0';
  132. info.accounting = user._id;
  133. } else {
  134. info.status = '2';
  135. info.leader = user._id;
  136. }
  137. let res;
  138. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  139. ...info,
  140. ...that.searchInfo
  141. });
  142. if (res.errcode == '0') {
  143. let list = [...that.list, ...res.data];
  144. for (let val of list) {
  145. val.zhStatus = that.searchStatus(val.status)
  146. }
  147. that.$set(that, `list`, list);
  148. that.$set(that, `total`, res.total)
  149. } else {
  150. uni.showToast({
  151. title: res.errmsg,
  152. icon: 'none'
  153. })
  154. }
  155. },
  156. // 查看详情
  157. toInfo(item) {
  158. console.log(item);
  159. },
  160. // 查询状态
  161. searchStatus(e) {
  162. const that = this;
  163. let data = that.statusList.find((i) => i.value == e);
  164. if (data) return data.label
  165. else return '暂无'
  166. },
  167. // 分页
  168. toPage(e) {
  169. const that = this;
  170. let list = that.list;
  171. let limit = that.limit;
  172. if (that.total > list.length) {
  173. uni.showLoading({
  174. title: '加载中',
  175. mask: true
  176. })
  177. let page = that.page + 1;
  178. that.$set(that, `page`, page)
  179. let skip = page * limit;
  180. that.$set(that, `skip`, skip)
  181. that.search();
  182. uni.hideLoading();
  183. } else that.$set(that, `is_bottom`, true)
  184. },
  185. // 触底
  186. toScroll(e) {
  187. const that = this;
  188. let up = that.scrollTop;
  189. that.$set(that, `scrollTop`, e.detail.scrollTop);
  190. let num = Math.sign(up - e.detail.scrollTop);
  191. if (num == 1) that.$set(that, `is_bottom`, false);
  192. },
  193. // 输入框
  194. toInput(e) {
  195. const that = this;
  196. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  197. else that.$set(that, `searchInfo`, {})
  198. that.clearPage();
  199. that.search();
  200. },
  201. // 审核
  202. async toExam(item, type) {
  203. const that = this;
  204. let user = that.user;
  205. let obj = {};
  206. if (type == '0') {
  207. if (user.role == 'kj') obj.status = '2';
  208. else obj.status = '4';
  209. } else {
  210. if (user.role == 'kj') obj.status = '-2';
  211. else obj.status = '-3';
  212. }
  213. uni.showModal({
  214. title: '提示',
  215. content: '确定审核该订单吗?',
  216. success: async function(res) {
  217. if (res.confirm) {
  218. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  219. if (res.errcode == '0') {
  220. uni.showToast({
  221. title: '维护信息成功',
  222. icon: 'none'
  223. })
  224. that.clearPage()
  225. that.search()
  226. } else {
  227. uni.showToast({
  228. title: res.errmsg,
  229. icon: 'none'
  230. })
  231. }
  232. }
  233. }
  234. });
  235. },
  236. // 查询其他信息
  237. async searchOther() {
  238. const that = this;
  239. let res;
  240. // 查询状态
  241. res = await that.$api(`/DictData`, 'GET', {
  242. type: 'order_status'
  243. })
  244. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  245. },
  246. // 清空列表
  247. clearPage() {
  248. const that = this;
  249. that.$set(that, `list`, [])
  250. that.$set(that, `skip`, 0)
  251. that.$set(that, `limit`, 6)
  252. that.$set(that, `page`, 0)
  253. }
  254. }
  255. }
  256. </script>
  257. <style lang="scss">
  258. .content {
  259. display: flex;
  260. flex-direction: column;
  261. width: 100vw;
  262. height: 100vh;
  263. .one {
  264. padding: 2vw;
  265. input {
  266. padding: 2vw;
  267. background-color: var(--f1Color);
  268. font-size: var(--font14Size);
  269. border-radius: 5px;
  270. }
  271. }
  272. .two {
  273. position: relative;
  274. flex-grow: 1;
  275. background-color: var(--f9Color);
  276. .list {
  277. background-color: #fff;
  278. border: 1px solid var(--f5Color);
  279. padding: 2vw;
  280. margin: 2vw 2vw 0 2vw;
  281. border-radius: 5px;
  282. .list_1 {
  283. display: flex;
  284. justify-content: space-between;
  285. padding: 2vw 0;
  286. font-size: var(--font16Size);
  287. .status {
  288. font-size: var(--font14Size);
  289. color: var(--fF0Color);
  290. }
  291. }
  292. .list_2 {
  293. display: flex;
  294. .left {
  295. .image {
  296. width: 20vw;
  297. height: 20vw;
  298. border-radius: 5px;
  299. }
  300. }
  301. .right {
  302. width: 70vw;
  303. margin: 0 0 0 2vw;
  304. .right_1 {
  305. display: flex;
  306. justify-content: space-between;
  307. margin: 2vw 0;
  308. .name {
  309. font-size: var(--font14Size);
  310. }
  311. .num {
  312. display: flex;
  313. flex-direction: column;
  314. align-items: flex-end;
  315. text:last-child {
  316. font-size: var(--font13Size);
  317. color: var(--f85Color);
  318. }
  319. }
  320. }
  321. .right_2 {
  322. font-size: var(--font12Size);
  323. color: var(--f85Color);
  324. }
  325. }
  326. }
  327. .bottom {
  328. text-align: center;
  329. padding: 1vw 0;
  330. button {
  331. margin: 0 5px 0 0;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. .scroll-view {
  338. position: absolute;
  339. top: 0;
  340. left: 0;
  341. right: 0;
  342. bottom: 0;
  343. .list-scroll-view {
  344. display: flex;
  345. flex-direction: column;
  346. }
  347. }
  348. .is_bottom {
  349. text-align: center;
  350. text {
  351. padding: 2vw 0;
  352. display: inline-block;
  353. color: var(--f85Color);
  354. font-size: var(--font14Size);
  355. }
  356. }
  357. </style>