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

276 lines
7.5 KiB

5 years ago
5 years ago
5 years ago
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. // return
  168. if(this.contents.length <= 0) {
  169. return this.$msg('您未选择物资')
  170. }
  171. var list = []
  172. for(var i;i< this.contents.length;i++) {
  173. console.log('出库数量')
  174. return
  175. if(Number(this.contents[i].delivery_number.value) > this.contents[i].stock) {
  176. this.$msg('库存数不足'+this.contents[i].stock)
  177. return
  178. }
  179. list.push({
  180. m_id: this.contents[i].material_id,
  181. m_spec_id: this.contents[i].spec_id,
  182. purchase_id: this.contents[i].purchase_id,
  183. out_number: Number(this.contents[i].delivery_number.value) || 1,
  184. warehouse_id: this.contents[i].order_id || 0,
  185. tax_price: this.contents[i].tax_price || '', // TODO 添加物资页面未返回价格,默认空
  186. non_tax_price: this.contents[i].non_tax_price || '',
  187. m_unit_id: this.contents[i].m_unit_id || 0
  188. })
  189. }
  190. // let list = this.contents.map(item => {
  191. // if(Number(item.delivery_number.value) > item.stock) {
  192. // this.$msg('库存数不足'+item.stock)
  193. // return
  194. // }
  195. // return {
  196. // m_id: item.material_id,
  197. // m_spec_id: item.spec_id,
  198. // purchase_id: item.purchase_id,
  199. // out_number: Number(item.delivery_number.value) || 1,
  200. // warehouse_id: item.order_id || 0,
  201. // tax_price: item.tax_price || '', // TODO 添加物资页面未返回价格,默认空
  202. // non_tax_price: item.non_tax_price || '',
  203. // m_unit_id: item.m_unit_id || 0
  204. // }
  205. // });
  206. console.log('==========',list)
  207. let _api = this.API.API_CANTEEN_WAREHOUSEOUT;
  208. if(this.enter_type == 1){
  209. _api = this.API.API_EDITOUTORDER;
  210. }
  211. let state = ['待确认', '已确认'][_t]; // 传入状态
  212. this.$http(_api, {
  213. data: list,
  214. state: state
  215. }).then(res => {
  216. this.$msg('操作成功').then(() => this.$toBack());
  217. })
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped="scoped">
  223. .lf-m-t-5{
  224. margin-top: 5rpx;
  225. }
  226. .lf-icon{
  227. padding: 2rpx 10rpx;
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. }
  232. .list{
  233. padding: 30rpx 32rpx;
  234. width: 100%;
  235. height: max-content;
  236. box-sizing: border-box;
  237. }
  238. .fixed-bottom{
  239. position: fixed;
  240. bottom: 0rpx;
  241. left: 0rpx;
  242. z-index: 99;
  243. width: 750rpx;
  244. height: 98rpx;
  245. display: flex;
  246. justify-content: center;
  247. align-items: center;
  248. border-top: 1rpx solid #E5E5E5;
  249. background-color: #fff;
  250. .btn{
  251. width: 320rpx;
  252. height: 82rpx;
  253. border-radius: 41rpx;
  254. margin: 0;
  255. padding: 0;
  256. font-size: 32rpx;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. }
  261. .btn1{
  262. border: 2rpx solid #555555;
  263. opacity: .5;
  264. }
  265. .btn2{
  266. background: #11D189;
  267. color: #FFFFFF;
  268. margin-left: 50rpx;
  269. }
  270. }
  271. </style>