index.vue 8.1 KB

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