index.vue 8.7 KB

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