my-oiling.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view>
  3. <my-add-button
  4. @handleClick="addChange"
  5. :is-batch="true"
  6. :button-list="addButtonList"
  7. />
  8. <!-- <view class="border-bottom">
  9. <u-tabs
  10. class="p-fixed left0 right0 zIndex"
  11. :list="list"
  12. :name="'label'"
  13. :is-scroll="true"
  14. :current="current"
  15. @change="change"
  16. ></u-tabs>
  17. </view> -->
  18. <common-tabs :list="list" :current="current" @change="change" />
  19. <my-page
  20. :loadData="loadData"
  21. :swipe-action="true"
  22. :row-show-params="{
  23. statusValue: $DictCache.VALUE.SB_OIL_STATUS,
  24. statusMap: statusMap,
  25. statusColor: $DictCache.COLOR.SB_OIL_STATUS,
  26. }"
  27. @rowClick="handleDetail"
  28. :page-size="10"
  29. ref="myPage"
  30. >
  31. <template #pageRow="{ recordModel, rowShowParams }">
  32. <view
  33. class="mx3 my2 p3 bg-color-white box p-relative"
  34. @longpress="showMask(recordModel.id,$event)">
  35. <common-mask :item="recordModel" :maskId="maskId" @hide="maskId = 0" @del="handleDel(recordModel)" />
  36. <view class="d-flex j-between border-bottom pb-2 a-center">
  37. <view class="text-color-b f-size-26">{{
  38. recordModel.updateTime
  39. }}</view>
  40. <my-badge
  41. :text="rowShowParams.statusMap[recordModel.status]"
  42. :status="rowShowParams.statusColor[recordModel.status]"
  43. />
  44. </view>
  45. <view class="mt-2 d-flex j-between">
  46. <view class="text-color-3 f-size-32 f-weight-bold">{{
  47. recordModel.sbName
  48. }}</view>
  49. <view class="text-color-3 f-size-32 f-weight-bold">{{
  50. recordModel.storeName
  51. }}</view>
  52. </view>
  53. <view class="mt-2 d-flex j-between">
  54. <view class="f-size-26 text-color-6 f-weight-4 mt-2">
  55. {{ recordModel.sbNo }}
  56. </view>
  57. </view>
  58. <view class="d-flex j-end edit-box">
  59. <view
  60. class="text-color-3 f-size-32 edit"
  61. v-if="recordModel.status === rowShowParams.statusValue.OIL"
  62. >
  63. <view @click.stop="confirmHandle(recordModel)">确认</view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. </my-page>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. list: [],
  76. statusMap: {},
  77. current: 0,
  78. maskId: 0,
  79. addButtonList: [
  80. {
  81. text: '扫码',
  82. index: 0
  83. },
  84. {
  85. text: '新增',
  86. index: 1
  87. }
  88. ]
  89. };
  90. },
  91. onPullDownRefresh() {
  92. this.$refs.myPage.pagePullDownRefresh();
  93. },
  94. onReachBottom() {
  95. this.$refs.myPage.pageReachBottom();
  96. },
  97. created() {
  98. const sbOilStatusList = this.$DictCache.getChildrenList(
  99. this.$DictCache.TYPE.SB_OIL_STATUS
  100. );
  101. const statusList = [{ label: '全部', value: '' }];
  102. sbOilStatusList.forEach((item) => {
  103. if (
  104. item.value !== this.$DictCache.VALUE.SB_OIL_STATUS.APPLY &&
  105. item.value !== this.$DictCache.VALUE.SB_OIL_STATUS.REJECT
  106. ) {
  107. statusList.push(item);
  108. }
  109. });
  110. this.list = statusList;
  111. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  112. this.$DictCache.TYPE.SB_OIL_STATUS
  113. );
  114. },
  115. onShow() {
  116. this.$nextTick(() => {
  117. this.$refs.myPage.initPage();
  118. });
  119. },
  120. onLoad() {},
  121. onHide() {
  122. this.maskId = 0
  123. },
  124. methods: {
  125. addChange(select) {
  126. const index = select.index
  127. if (index === 0) {
  128. uni.scanCode({
  129. success(e) {
  130. console.log(e.result);
  131. if (e.result) {
  132. uni.navigateTo({
  133. url: '/pages/oiling/my-oiling-add?sbId=' + e.result
  134. });
  135. }
  136. }
  137. });
  138. } else if (index === 1) {
  139. uni.navigateTo({
  140. url: '/pages/oiling/my-oiling-add'
  141. });
  142. } else if (index === 2) {
  143. this.$Http
  144. .copySbOils({})
  145. .then((res) => {
  146. this.$refs.myPage.pagePullDownRefresh();
  147. });
  148. } else if (index === 3) {
  149. uni.navigateTo({
  150. url: '/pages/oiling/batch-oiling-select'
  151. });
  152. }
  153. },
  154. showMask(id, e) {
  155. this.maskId = id
  156. // #ifdef H5
  157. e.preventDefault()
  158. // #endif
  159. },
  160. // tab
  161. change(index, e) {
  162. this.current = index;
  163. this.$refs.myPage.initPage();
  164. },
  165. // 删除
  166. handleDel(recordModel) {
  167. const that = this;
  168. const params = [];
  169. params.push(recordModel.id);
  170. uni.showModal({
  171. title: '提示',
  172. content: '您确认删除吗?',
  173. success: (res) => {
  174. if (res.confirm) {
  175. this.$Http.deleteSbOils(params).then((res) => {
  176. uni.showToast({ title: '删除成功' });
  177. that.$refs.myPage.listData = [];
  178. that.$refs.myPage.loadMore = true;
  179. that.$refs.myPage.pageNum = 1;
  180. that.$refs.myPage.initData();
  181. });
  182. } else if (res.cancel) {
  183. }
  184. }
  185. });
  186. },
  187. loadData(parameter) {
  188. return this.$Http
  189. .getSbOilPage({
  190. ...parameter,
  191. filter: 1,
  192. status: this.list[this.current].value
  193. })
  194. .then((res) => {
  195. return res.data;
  196. });
  197. },
  198. confirmHandle(recordModel) {
  199. uni.navigateTo({
  200. url: '/pages/oiling/my-oiling-detail?confirm=1&id=' + recordModel.id
  201. });
  202. },
  203. // 详情
  204. handleDetail(recordModel) {
  205. if (this.maskId !== 0) {
  206. this.maskId = 0
  207. return
  208. }
  209. uni.navigateTo({
  210. url: '/pages/oiling/my-oiling-detail?id=' + recordModel.id
  211. });
  212. }
  213. }
  214. };
  215. </script>
  216. <style lang="less">
  217. .main {
  218. .box {
  219. border-radius: unit(20, rpx);
  220. padding-right: 0;
  221. }
  222. }
  223. page {
  224. background-color: #f4f4f4;
  225. }
  226. .edit-box {
  227. padding: 0 30rpx;
  228. margin-top: 40rpx;
  229. .edit {
  230. padding: 8rpx 40rpx;
  231. border: 1px solid #ddd;
  232. border-radius: 20rpx;
  233. font-size: 26rpx;
  234. color: #666;
  235. margin-left: 30rpx;
  236. }
  237. }
  238. </style>