index.vue 9.5 KB

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