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

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