viewArea.vue 6.4 KB

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