自主产品,供应链食堂系统。将两个端拆开了。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

237 lines
6.1 KiB

5 years ago
  1. <template>
  2. <view>
  3. <view class="list" @click="$url('/pages/classification/warehouse')">
  4. <view class="lf-font-28 lf-color-black lf-row-between">
  5. <view>出库清单</view>
  6. <view class="lf-icon">
  7. <u-icon name="plus-circle" size="42"></u-icon>
  8. </view>
  9. </view>
  10. <view class="lf-font-24 lf-color-gray lf-m-t-5">添加物资后可以编辑数量</view>
  11. </view>
  12. <!-- 修饰条 -->
  13. <self-line></self-line>
  14. <!-- 物料table -->
  15. <view class="list">
  16. <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view>
  17. <wyb-table :headers="headers" :contents="contents"
  18. contentBgColor="#ecfaf5"
  19. :first-line-fixed="true"
  20. @onInputChange="onInputChange"
  21. width="max-content" height="80vh"
  22. v-if="contents.length"></wyb-table>
  23. </view>
  24. <view style="height: 140rpx;"></view>
  25. <!-- 操作按钮 -->
  26. <view class="fixed-bottom lf-p-l-32 lf-p-r-32" style="justify-content: space-between;" v-if="enter_type == 1">
  27. <view></view>
  28. <!-- <button class="btn btn2" @click="editOrder()">立即申请</button> -->
  29. <button class="btn btn2" @click="save(1)">立即申请</button>
  30. </view>
  31. <view class="fixed-bottom" v-else>
  32. <button class="btn btn1" @click="save(0)">临时保存</button>
  33. <button class="btn btn2" @click="save(1)">直接申请</button>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import wybTable from '@/components/wyb-table/wyb-table';
  39. export default {
  40. components: {
  41. wybTable
  42. },
  43. data(){
  44. return {
  45. headers: [{
  46. label: '物资名称',
  47. key: 'material_name'
  48. },{
  49. label: '规格',
  50. key: 'spec_name'
  51. },{
  52. key: 'brand',
  53. label: '品牌'
  54. },{
  55. key: 'quality_level',
  56. label: '品级'
  57. },{
  58. label: '编号',
  59. key: 'm_sn'
  60. },{
  61. label: '供应商',
  62. key: 'supplier_name'
  63. },{
  64. label: '批次',
  65. key: 'batch_sn'
  66. },{
  67. key: 'delivery_number',
  68. label: '出库数量'
  69. }],
  70. contents: [],
  71. warehouse_list: {},
  72. enter_type: '', // 1 编辑,2 复用
  73. o_sn: ''
  74. }
  75. },
  76. onLoad(e){
  77. // 监听warehouse_list被操作
  78. uni.$on('addWarehouseList', res => {
  79. this.warehouse_list = res;
  80. })
  81. if(e){
  82. this.o_sn = e.o_sn
  83. this.enter_type = e.enter_type
  84. if(e.enter_type == 1 || e.enter_type == 2){
  85. this.getData();
  86. }
  87. }
  88. },
  89. onShow(){
  90. this.transformList();
  91. },
  92. methods: {
  93. transformList(){
  94. let contents = [];
  95. let warehouse_list = JSON.stringify(this.warehouse_list);
  96. warehouse_list = JSON.parse(warehouse_list);
  97. for(let i in warehouse_list){
  98. warehouse_list[i].delivery_number = {edit: true, value: warehouse_list[i].delivery_number || 1};
  99. contents.push(warehouse_list[i]);
  100. }
  101. this.contents = contents;
  102. console.log("show.warehouse_list...", this.warehouse_list)
  103. console.log("transformList...", contents);
  104. },
  105. // 复用 & 编辑
  106. getData(){
  107. // TODO 此处应该调此接口 出库单复用
  108. // this.$http(this.API.API_CANTEEN_WAREHOUSEOUTREUSE, {
  109. this.$http(this.API.API_CANTEEN_OUTDETAIL, {
  110. o_sn: this.o_sn
  111. }).then(res => {
  112. // let list = res.data || [];
  113. let list = res.data.sheet || [];
  114. let warehouse_list = {};
  115. list.map(item => {
  116. warehouse_list[item.id] = {
  117. batch_sn: item?.purchase?.batch_sn || '',
  118. brand: item?.material?.brand || '',
  119. checked: true,
  120. m_sn: item?.material?.m_sn || '',
  121. material_id: item?.material?.id || 0,
  122. material_name: item?.material?.m_name || '',
  123. order_id: item.id,
  124. purchase_id: item.purchase_id,
  125. quality_level: item?.material?.quality_level || '',
  126. spec_id: item?.spec?.id || 0,
  127. spec_name: item?.spec?.name || '',
  128. supplier_name: item?.purchase?.supplier?.supplier_name || '',
  129. delivery_number: item.out_number || 1
  130. };
  131. })
  132. this.warehouse_list = warehouse_list;
  133. this.transformList();
  134. })
  135. },
  136. //编辑出库 todo
  137. editOrder() {
  138. this.$http(this.API.API_EDITOUTORDER, {
  139. data: list
  140. }).then(res => {
  141. console.log("save", res);
  142. this.$msg('操作成功').then(() => this.$toBack());
  143. })
  144. },
  145. // table输入框
  146. onInputChange(event){
  147. console.log("检测到table input被更改", event);
  148. this.contents[event.contentIndex][event.key].value = event.detailValue;
  149. },
  150. // 保存,出库
  151. save(_t){
  152. console.log("dddddd", this.contents)
  153. if(this.contents.length <= 0) {
  154. return this.$msg('您未选择物资')
  155. }
  156. let list = this.contents.map(item => {
  157. return {
  158. m_id: item.material_id,
  159. m_spec_id: item.spec_id,
  160. purchase_id: item.purchase_id,
  161. out_number: Number(item.delivery_number.value) || 1,
  162. warehouse_id: item.order_id || 0,
  163. tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空
  164. non_tax_price: item.non_tax_price || '',
  165. m_unit_id: item.m_unit_id || 0
  166. }
  167. });
  168. console.log('==========',list)
  169. let _api = this.API.API_CANTEEN_WAREHOUSEOUT;
  170. if(this.enter_type == 1){
  171. _api = this.API.API_EDITOUTORDER;
  172. }
  173. let state = ['待确认', '已确认'][_t]; // 传入状态
  174. this.$http(_api, {
  175. data: list,
  176. state: state
  177. }).then(res => {
  178. this.$msg('操作成功').then(() => this.$toBack());
  179. })
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped="scoped">
  185. .lf-m-t-5{
  186. margin-top: 5rpx;
  187. }
  188. .lf-icon{
  189. padding: 2rpx 10rpx;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. }
  194. .list{
  195. padding: 30rpx 32rpx;
  196. width: 100%;
  197. height: max-content;
  198. box-sizing: border-box;
  199. }
  200. .fixed-bottom{
  201. position: fixed;
  202. bottom: 0rpx;
  203. left: 0rpx;
  204. z-index: 99;
  205. width: 750rpx;
  206. height: 98rpx;
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. border-top: 1rpx solid #E5E5E5;
  211. background-color: #fff;
  212. .btn{
  213. width: 320rpx;
  214. height: 82rpx;
  215. border-radius: 41rpx;
  216. margin: 0;
  217. padding: 0;
  218. font-size: 32rpx;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. }
  223. .btn1{
  224. border: 2rpx solid #555555;
  225. opacity: .5;
  226. }
  227. .btn2{
  228. background: #11D189;
  229. color: #FFFFFF;
  230. margin-left: 50rpx;
  231. }
  232. }
  233. </style>