自主产品,供应链食堂系统。将两个端拆开了。
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.

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