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

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