viewArea.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div>
  3. <el-dialog title="查看库区" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
  4. <div style="display: flex;align-items: center;">
  5. <dic-select
  6. v-if="dialogVisible"
  7. style="width: 300px;"
  8. v-model="query.dot"
  9. placeholder="批次号"
  10. label="dot"
  11. :disabled="true"
  12. :url="'/blade-sales-part/stockDesc/dotList?storageId=' + form.storageId + '&goodsId=' + query.goodsId"
  13. :filterable="true"
  14. @selectChange="dicChange('dot', $event)"
  15. ></dic-select>
  16. <el-tag type="danger" style="margin-left: 10px;">出库数量:{{ qtyMax }}</el-tag>
  17. </div>
  18. <avue-crud
  19. v-if="dialogVisible"
  20. :option="option"
  21. :table-loading="loading"
  22. :data="data"
  23. ref="crud"
  24. id="out-table"
  25. :header-cell-class-name="headerClassName"
  26. >
  27. <template slot="quantity" slot-scope="{ row }">
  28. <el-input-number
  29. v-model="row.quantity"
  30. size="small"
  31. :controls="false"
  32. style="width: 100%"
  33. :max="row.balanceQuantity"
  34. :disabled="disabled"
  35. @change="qtyChange(row)"
  36. />
  37. </template>
  38. </avue-crud>
  39. <span slot="footer" class="dialog-footer">
  40. <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
  41. <el-button type="primary" @click="submit" size="mini">确 认</el-button>
  42. </span>
  43. </el-dialog>
  44. </div>
  45. </template>
  46. <script>
  47. import { selectReservoirAreaList } from "@/api/tirePartsMall/salesManagement/outboundWorkOrder";
  48. import { head } from "lodash";
  49. import { isProcurement } from "@/api/basicData/configuration";
  50. import dicSelect from "@/components/dicSelect/main";
  51. export default {
  52. props: {
  53. disabled: {
  54. type: Boolean,
  55. default: false
  56. }
  57. },
  58. components: {
  59. dicSelect
  60. },
  61. data() {
  62. return {
  63. data: [],
  64. dialogVisible: false,
  65. loading: false,
  66. option: {
  67. height: 500,
  68. calcHeight: 30,
  69. border: true,
  70. index: true,
  71. addBtn: false,
  72. viewBtn: false,
  73. delBtn: false,
  74. editBtn: false,
  75. columnBtn: false,
  76. menu: false,
  77. header: false,
  78. column: [
  79. {
  80. label: "库区",
  81. prop: "reservoirAreaName",
  82. filters: true,
  83. sortable: true,
  84. overHidden: true
  85. },
  86. {
  87. label: "批次",
  88. prop: "dot",
  89. overHidden: true
  90. },
  91. {
  92. label: "库存",
  93. prop: "balanceQuantity",
  94. overHidden: true
  95. },
  96. {
  97. label: "本次数量",
  98. prop: "quantity",
  99. overHidden: true
  100. }
  101. ]
  102. },
  103. form: {},
  104. query: {},
  105. index: 0,
  106. qtyMax: 0
  107. };
  108. },
  109. async created() {},
  110. methods: {
  111. dicChange(name, row) {
  112. if (name == "dot") {
  113. if (row) {
  114. this.query.inventory = row.balanceQuantity;
  115. this.onLoad();
  116. } else {
  117. this.query.dot = null;
  118. this.onLoad();
  119. }
  120. }
  121. },
  122. qtyChange(row) {
  123. let sum = 0;
  124. for (let item of this.data) {
  125. sum += Number(item.quantity);
  126. }
  127. if (sum > this.qtyMax) {
  128. return this.$message.error("总数量不能超过" + this.qtyMax);
  129. }
  130. },
  131. onLoad() {
  132. let obj = {
  133. shipId: this.form.id,
  134. shipItemId: this.query.id,
  135. goodsId: this.query.goodsId,
  136. storageId: this.form.storageId,
  137. dot: this.query.dot
  138. };
  139. this.loading = true;
  140. selectReservoirAreaList(obj)
  141. .then(res => {
  142. this.data = res.data.data;
  143. })
  144. .finally(() => {
  145. this.loading = false;
  146. });
  147. },
  148. openDialog(form, row, index) {
  149. this.form = {};
  150. this.query = {};
  151. this.index = null;
  152. this.data = [];
  153. this.qtyMax = 0;
  154. this.form = form;
  155. this.query = row;
  156. this.index = index;
  157. this.data = this.deepClone(row.historyList);
  158. this.qtyMax = row.remainingNum;
  159. this.dialogVisible = true;
  160. if (row.historyList.length == 0) {
  161. this.onLoad();
  162. }
  163. },
  164. submit() {
  165. if (this.data.filter(item => item.quantity > 0).length == 0) {
  166. return this.$message.error("至少有一条本次数量不能为0");
  167. }
  168. let sum = 0;
  169. for (let item of this.data) {
  170. sum += Number(item.quantity);
  171. }
  172. if (sum > this.qtyMax) {
  173. return this.$message.error("总数量不能超过" + this.qtyMax);
  174. }
  175. let obj = {
  176. ...this.query,
  177. sendNum: sum,
  178. historyList: this.data.filter(item => item.quantity > 0)
  179. };
  180. this.$emit("areaData", obj, this.index);
  181. this.dialogVisible = false;
  182. },
  183. //自定义列保存
  184. async saveColumn(ref, option, optionBack, code) {
  185. /**
  186. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  187. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  188. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  189. */
  190. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  191. if (inSave) {
  192. this.$message.success("保存成功");
  193. //关闭窗口
  194. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  195. this.searchReset();
  196. }
  197. },
  198. //自定义列重置
  199. async resetColumn(ref, option, optionBack, code) {
  200. this[option] = this[optionBack];
  201. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  202. if (inSave) {
  203. this.$message.success("重置成功");
  204. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  205. }
  206. },
  207. // 更改表格颜色
  208. headerClassName(tab) {
  209. //颜色间隔
  210. let back = "";
  211. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  212. if (tab.columnIndex % 2 === 0) {
  213. back = "back-one";
  214. } else if (tab.columnIndex % 2 === 1) {
  215. back = "back-two";
  216. }
  217. }
  218. return back;
  219. }
  220. }
  221. };
  222. </script>
  223. <style scoped>
  224. ::v-deep#out-table .back-one {
  225. background: #ecf5ff !important;
  226. text-align: center;
  227. padding: 4px 0;
  228. }
  229. ::v-deep#out-table .back-two {
  230. background: #ecf5ff !important;
  231. text-align: center;
  232. padding: 4px 0;
  233. }
  234. </style>