list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view>
  3. <scroll-view :scroll-y="true">
  4. <view class="cu-bar bg-white solid-bottom">
  5. <view class="action">
  6. <text class="cuIcon-title text-orange "></text>
  7. 排产计划列表
  8. </view>
  9. <view class="action">
  10. <button class="cu-btn bg-blue shadow" @click="addClick">新增</button>
  11. <button style="margin-left: 5px;" class="cu-btn bg-green shadow" @click="showCount">统计</button>
  12. </view>
  13. </view>
  14. <scroll-view scroll-x class="bg-white nav">
  15. <view class="flex text-center">
  16. <view class="cu-item flex-sub" :class="index == TabCur ? 'text-orange cur' : ''" v-for="(item, index) in tabs" :key="index" @tap="tabSelect" :data-id="index">
  17. {{ item.name }}
  18. </view>
  19. </view>
  20. </scroll-view>
  21. <view class="cu-list menu">
  22. <view
  23. class="cu-item"
  24. :class="modalName == 'move-box-' + index ? 'move-cur' : ''"
  25. v-for="(item, index) in planList"
  26. :key="index"
  27. @touchstart="ListTouchStart"
  28. @touchmove="ListTouchMove"
  29. @touchend="ListTouchEnd"
  30. :data-target="'move-box-' + index"
  31. >
  32. <!-- <view class="content"> -->
  33. <view class="text-gray" style="width: 45%;">{{ item.orderNo }}({{ item.filing.workshop.zyProductWorkshop }}-{{ item.filing.team.zyTeam }})</view>
  34. <view class="text-gray" style="width: 5%;">{{ item.qty }}</view>
  35. <view class="text-gray" style="width: 5%;">{{ item.workShift }}</view>
  36. <view class="text-gray" style="width: 20%;">{{ item.createDate }}</view>
  37. <!-- </view> -->
  38. <view class="move">
  39. <!-- <view class="bg-grey" @click="editPlanInfo(item)">修改</view> -->
  40. <view v-if="TabCur == 0" class="bg-green" @click="finish(item)">完成</view>
  41. <view class="bg-red" @click="deletePlanInfo(item)">删除</view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- <view class="warp">
  46. <view class="box">
  47. <t-table @change="change">
  48. <t-tr font-size="14">
  49. <t-th>订单号</t-th>
  50. <t-th>数量</t-th>
  51. <t-th>班制</t-th>
  52. <t-th>操作</t-th>
  53. </t-tr>
  54. <t-tr v-for="(item, index) in planList" :key="index" font-size="12">
  55. <t-td>{{ item.orderNo }}</t-td>
  56. <t-td>{{ item.qty }}</t-td>
  57. <t-td>{{ item.workShift }}</t-td>
  58. <t-td class="move" align="left">
  59. <button size="mini" @click="editPlanInfo(item)">编辑</button>
  60. <button size="mini" @click="deletePlanInfo(item)">删除</button>
  61. </t-td>
  62. </t-tr>
  63. </t-table>
  64. </view>
  65. </view> -->
  66. </scroll-view>
  67. </view>
  68. </template>
  69. <script>
  70. // import tTable from '@/components/t-table/t-table.vue';
  71. // import tTh from '@/components/t-table/t-th.vue';
  72. // import tTr from '@/components/t-table/t-tr.vue';
  73. // import tTd from '@/components/t-table/t-td.vue';
  74. import { deletePlan, list, finishPlan } from '@/api/biz/plan.js';
  75. export default {
  76. // components: {
  77. // tTable,
  78. // tTh,
  79. // tTr,
  80. // tTd
  81. // },
  82. data() {
  83. return {
  84. planList: [],
  85. modalName: null,
  86. tabs: [
  87. {
  88. key: 0,
  89. name: '未完成'
  90. },
  91. {
  92. key: 1,
  93. name: '已完成'
  94. }
  95. ],
  96. TabCur: 0
  97. };
  98. },
  99. methods: {
  100. addClick() {
  101. uni.navigateTo({
  102. url: '/pages/plan/index'
  103. });
  104. },
  105. showCount(item) {
  106. uni.navigateTo({
  107. url: '/pages/plan/count'
  108. });
  109. },
  110. // ListTouch触摸开始
  111. ListTouchStart(e) {
  112. this.listTouchStart = e.touches[0].pageX;
  113. },
  114. // ListTouch计算方向
  115. ListTouchMove(e) {
  116. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left';
  117. },
  118. // ListTouch计算滚动
  119. ListTouchEnd(e) {
  120. if (this.listTouchDirection == 'left') {
  121. this.modalName = e.currentTarget.dataset.target;
  122. } else {
  123. this.modalName = null;
  124. }
  125. this.listTouchDirection = null;
  126. },
  127. editPlanInfo(item) {
  128. uni.navigateTo({
  129. url: '/pages/plan/edit?planInfo=' + encodeURIComponent(JSON.stringify(item))
  130. });
  131. },
  132. finish(item) {
  133. uni.showModal({
  134. title: '提示',
  135. content: '确定计划完成吗',
  136. success: res => {
  137. if (res.confirm) {
  138. console.log('确定');
  139. finishPlan(item).then(res => {
  140. if (res.success) {
  141. this.removePlanInfo(item);
  142. } else {
  143. }
  144. });
  145. } else if (res.cancel) {
  146. console.log('取消');
  147. }
  148. }
  149. });
  150. },
  151. deletePlanInfo(item) {
  152. deletePlan(item).then(res => {
  153. if (res.success) {
  154. this.removePlanInfo(item);
  155. } else {
  156. }
  157. });
  158. },
  159. removePlanInfo(item) {
  160. const index = this.planList.findIndex(ele => {
  161. return ele.id == item.id;
  162. });
  163. this.planList.splice(index, 1);
  164. },
  165. // loadData() {
  166. // list().then(res => {
  167. // if (res.success) {
  168. // this.planList = res.data;
  169. // } else {
  170. // }
  171. // });
  172. // },
  173. loadData(tabIndex) {
  174. list(tabIndex).then(res => {
  175. if (res.success) {
  176. this.planList = res.data;
  177. } else {
  178. }
  179. });
  180. },
  181. tabSelect(e) {
  182. this.TabCur = e.currentTarget.dataset.id;
  183. this.loadData(this.TabCur);
  184. }
  185. },
  186. onLoad() {
  187. this.loadData(0);
  188. uni.$on('loadData', data => {
  189. this.TabCur = 0;
  190. // console.log('xiugai' + data);
  191. this.loadData(0);
  192. });
  193. }
  194. };
  195. </script>
  196. <style></style>