index.vue 8.9 KB

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