order-in-table.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <el-row class="addForm">
  3. <el-col :span="24">
  4. <el-form
  5. :model="tableForm"
  6. :rules="tableFormThis"
  7. ref="tableForm"
  8. :size="'mini'"
  9. class="demo-tableForm product_go"
  10. >
  11. <el-table :data="tableForm.product_go" border :size="'mini'" row-key="key">
  12. <template v-for="(item, index) in columns">
  13. <el-table-column
  14. :prop="item.prop"
  15. show-overflow-tooltip
  16. :label="item.label"
  17. :width="item.width"
  18. :min-width="item.minWidth"
  19. :key="item.prop + index"
  20. />
  21. </template>
  22. <el-table-column fixed="right" width="80">
  23. <template slot="header" slot-scope="scope">
  24. <el-tooltip
  25. class="fr"
  26. style="margin: 3px 0 0 0"
  27. v-if="
  28. ((status + '' === '1' && powers.some((i) => i == '028')) ||
  29. (status + '' === '2' && powers.some((i) => i == '028'))) &&
  30. sitem &&
  31. ((currentLevel === '3' &&
  32. (sitem.order_type + '' === '2' ||
  33. sitem.order_type + '' === '3' ||
  34. sitem.order_type + '' === '4')) ||
  35. sitem.order_type + '' === '1')
  36. "
  37. effect="dark"
  38. content="添加"
  39. placement="top"
  40. >
  41. <i
  42. class="el-icon-circle-plus-outline tb-icon"
  43. style="color: #6954f0"
  44. @click="openModal()"
  45. />
  46. </el-tooltip>
  47. <span v-else>操作</span>
  48. </template>
  49. <template slot-scope="scope">
  50. <el-tooltip
  51. v-if="powers.some((i) => i == '007')"
  52. effect="dark"
  53. content="详情"
  54. placement="top"
  55. >
  56. <i
  57. class="el-icon-view tb-icon"
  58. @click="
  59. routeGoto('supplierWsmInOrderDetail', {
  60. id: scope.row.wsm_in_code,
  61. })
  62. "
  63. ></i>
  64. </el-tooltip>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. </el-form>
  69. <wsm-in-order-model
  70. :show-model="showModel"
  71. :sitem="modelSitem"
  72. @refresh="(showModel = false), $emit('refresh')"
  73. @cancel="showModel = false"
  74. />
  75. </el-col>
  76. </el-row>
  77. </template>
  78. <script>
  79. import asyncRequest from "@/apis/service/stock/allot/detail";
  80. //?
  81. import resToken from "@/mixins/resToken";
  82. import config from "./columns-table"; //表格列参数
  83. import wsmInOrderModel from "@/views/purchaseIn/wsmInOrder/components/wsm-in-order-model";
  84. import { mapGetters } from "vuex";
  85. export default {
  86. name: "allot",
  87. props: ["id", "sitem", "newTime"],
  88. mixins: [resToken],
  89. components: { wsmInOrderModel },
  90. computed: {
  91. ...mapGetters(["currentLevel"]),
  92. powers() {
  93. const tran =
  94. this.$store.getters.btnList.find(
  95. (item) => item.menu_route == "supplierPurchaseOrderDetail"
  96. ) || {};
  97. const { action } = tran ?? {};
  98. return action ?? [];
  99. },
  100. },
  101. data() {
  102. return {
  103. showModel: false,
  104. isDetail: false,
  105. modelId: 0,
  106. options: [],
  107. status: "",
  108. loading: false,
  109. modelSitem: null,
  110. wsm_in_code: "",
  111. tableForm: {
  112. product_go: [], //出库商品
  113. },
  114. tableFormThis: config.tableFormThis,
  115. statusOptions: [
  116. { value: "1",label: "待库管验货",},
  117. { value: "2",label: "入库完成",}
  118. ],
  119. columns: config.columns,
  120. };
  121. },
  122. watch: {
  123. newTime: function (val) {
  124. if (val) {
  125. this.initForm();
  126. }
  127. },
  128. },
  129. mounted() {
  130. this.initForm();
  131. },
  132. methods: {
  133. async initForm() {
  134. this.loading = true;
  135. this.modelSitem = null;
  136. await this.resetForm();
  137. this.loading = false;
  138. },
  139. async resetForm() {
  140. // 重置
  141. await this.$nextTick(() => {
  142. if (this.$refs.tableForm) {
  143. this.$refs.tableForm.resetFields();
  144. this.$refs.tableForm.clearValidate();
  145. const { status, child } = this.sitem;
  146. this.status = status;
  147. this.tableForm.product_go = child || [];
  148. this.tableForm.product_go.forEach((e) => {
  149. e.sendtype_name =
  150. e.sendtype + "" === "1"
  151. ? "公司自提"
  152. : e.sendtype === "2"
  153. ? "供应商包邮"
  154. : "--";
  155. e.status_name =
  156. (this.statusOptions.find((item) => item.value == e.status) || {}).label ||
  157. "--";
  158. });
  159. }
  160. });
  161. },
  162. openModal() {
  163. this.modelSitem = this.sitem;
  164. this.showModel = true;
  165. },
  166. async submitForm() {
  167. if (this.loading) {
  168. return;
  169. }
  170. let good = [];
  171. this.loading = true;
  172. good = this.getGoodList();
  173. const model = {
  174. allot_code: this.sitem.allot_code,
  175. good: good,
  176. };
  177. let res = {};
  178. if (this.status == "3") {
  179. res = await asyncRequest.allotgetin(model);
  180. } else {
  181. res = await asyncRequest.allotvesio(model);
  182. }
  183. this.loading = false;
  184. if (res && res.code === 0) {
  185. this.$notify.success({
  186. title:
  187. this.status == "3" ? "入库方验货结果提交成功!" : "入库方验货审核结果提交成功",
  188. message: "",
  189. });
  190. this.$emit("refresh");
  191. } else if (res && res.code >= 100 && res.code <= 104) {
  192. await this.logout();
  193. } else {
  194. this.$message.warning(res.message);
  195. }
  196. },
  197. //提交表单前 商品信息list 汇总
  198. getGoodList() {
  199. let oldList = JSON.parse(JSON.stringify(this.tableForm.product_go)),
  200. resList = [];
  201. oldList.forEach((v1) => {
  202. let goodModel = {
  203. good_code: v1.type_code,
  204. usable_num: v1.usable_stock,
  205. error_num: v1.error_num,
  206. error_remark: v1.error_remark,
  207. error_code: v1.error_code,
  208. };
  209. if (this.status + "" === "4") {
  210. goodModel.stock_num = v1.stock_num;
  211. }
  212. resList.push(goodModel);
  213. });
  214. return resList;
  215. },
  216. },
  217. };
  218. </script>
  219. <style lang="scss" scoped>
  220. .allot,
  221. .allotDetail {
  222. .label-title-model {
  223. line-height: 30px;
  224. width: 100%;
  225. color: #909399;
  226. font-weight: bold;
  227. font-size: 15px;
  228. padding-bottom: 12px;
  229. text-align: center;
  230. }
  231. .product_go {
  232. .el-form-item--mini.el-form-item {
  233. margin: 0 !important;
  234. .spscope {
  235. word-break: break-all !important;
  236. line-height: 23px !important;
  237. padding: 0 !important;
  238. margin: 0 !important;
  239. list-style: none !important;
  240. font-style: normal !important;
  241. text-decoration: none !important;
  242. border: none !important;
  243. display: inline-block !important;
  244. font-weight: 500 !important;
  245. font-family: "Microsoft Yahei", sans-serif !important;
  246. -webkit-tap-highlight-color: transparent !important;
  247. -webkit-font-smoothing: antialiased !important;
  248. color: #606266 !important;
  249. font-size: 12px !important;
  250. }
  251. }
  252. }
  253. }
  254. </style>