index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!-- 采购需求处理-详情 -->
  2. <script>
  3. import useColumns from "./columns";
  4. import {
  5. getSummaryDetail,
  6. shutDownSummary,
  7. editSummaryMx,
  8. reloadBatch,
  9. } from "@/api/purchase/DemandSummary.js";
  10. export default {
  11. name: "DemandSummaryAdd",
  12. props: {
  13. dict: {
  14. type: Object,
  15. },
  16. data: {
  17. type: Object,
  18. },
  19. },
  20. components: {
  21. CloseLineBtn: () => import("../closeLine/index.vue"),
  22. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  23. ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
  24. },
  25. data() {
  26. const { TableColumns } = useColumns();
  27. return {
  28. width: "100%",
  29. title: "详 情",
  30. isEdit: false,
  31. visible: false,
  32. loading: false,
  33. params: [],
  34. TableColumns,
  35. selectData: [],
  36. };
  37. },
  38. computed: {
  39. height: {
  40. get() {
  41. return window.innerHeight - 150;
  42. },
  43. set() {},
  44. },
  45. },
  46. methods: {
  47. onHide() {
  48. this.visible = false;
  49. this.params = [];
  50. this.selectData = [];
  51. this.$emit("refresh");
  52. },
  53. setVisible(prop) {
  54. this.visible = prop;
  55. },
  56. beforeOpen() {
  57. this.fetchItem();
  58. },
  59. async fetchItem() {
  60. try {
  61. this.loading = true;
  62. let { code, msg, data } = await getSummaryDetail({
  63. ...this.$props.data,
  64. });
  65. if (code == 200) {
  66. this.params = data;
  67. }
  68. } catch (error) {
  69. } finally {
  70. this.loading = false;
  71. }
  72. },
  73. useSelect(prop) {
  74. this.selectData = prop;
  75. },
  76. // 编辑
  77. useEdit() {
  78. this.isEdit = true;
  79. },
  80. // 取消
  81. useCancel() {
  82. this.isEdit = false;
  83. this.fetchItem();
  84. },
  85. // 保存
  86. async useSave() {
  87. try {
  88. const params = [...this.params];
  89. console.log(params, "params");
  90. let { code, msg } = await editSummaryMx(params);
  91. if (code == 200) {
  92. this.$modal.notifySuccess(msg);
  93. this.isEdit = false;
  94. this.fetchItem();
  95. }
  96. } catch (error) {}
  97. },
  98. // 重取批量
  99. refetchBatch() {
  100. this.$modal
  101. .confirm("是否更新明细的最小包装量,最小订货量,最小批量?")
  102. .then(async () => {
  103. let ids = this.params.map((item) => item.demandItemId);
  104. let { code, msg } = await reloadBatch(ids);
  105. if (code == 200) {
  106. this.$modal.notifySuccess(msg);
  107. this.fetchItem();
  108. }
  109. })
  110. .catch(() => {});
  111. },
  112. // 补单标识
  113. changeReplenishment(prop, row) {
  114. if (prop === "N") {
  115. row.additionalSupplier = null;
  116. row.additionalSupplierName = null;
  117. }
  118. },
  119. },
  120. created() {},
  121. };
  122. </script>
  123. <template>
  124. <el-drawer
  125. v-loading="loading"
  126. v-bind="$attrs"
  127. v-on="$listeners"
  128. :size="width"
  129. :show-close="false"
  130. :visible.sync="visible"
  131. destroy-on-close
  132. @close="onHide"
  133. @open="beforeOpen"
  134. >
  135. <div
  136. slot="title"
  137. style="display: flex; justify-content: space-between; align-items: center"
  138. >
  139. <h3>{{ title }}</h3>
  140. <el-row class="my-4" style="text-align: right">
  141. <el-col v-if="isEdit">
  142. <el-button-group>
  143. <el-button type="primary" :size="$attrs.size" @click="useSave"
  144. >保 存</el-button
  145. >
  146. <el-button :size="$attrs.size" @click="useCancel">取 消</el-button>
  147. </el-button-group>
  148. </el-col>
  149. <el-col v-else>
  150. <el-button-group>
  151. <el-button type="primary" :size="$attrs.size" @click="useEdit"
  152. >编 辑</el-button
  153. >
  154. </el-button-group>
  155. <el-button-group>
  156. <close-line-btn
  157. :size="$attrs.size"
  158. :select-data="selectData"
  159. @refresh="fetchItem"
  160. ></close-line-btn>
  161. </el-button-group>
  162. <el-button-group>
  163. <el-button :size="$attrs.size" @click="refetchBatch"
  164. >重取批量</el-button
  165. >
  166. </el-button-group>
  167. <el-button-group>
  168. <el-button :size="$attrs.size" :loading="loading" @click="onHide">
  169. 返回
  170. </el-button>
  171. </el-button-group>
  172. </el-col>
  173. </el-row>
  174. </div>
  175. <el-super-ux-table
  176. v-model="params"
  177. :dict="dict"
  178. :height="height"
  179. :size="$attrs.size"
  180. :columns="TableColumns"
  181. index
  182. checkbox
  183. convenitentOperation
  184. storage-key="DemandSummaryDetailsSuperTable"
  185. @row-select="useSelect"
  186. style="padding: 0 20px 20px"
  187. >
  188. <!-- 紧急标识-->
  189. <template slot="isUrgency" slot-scope="scope">
  190. <component
  191. v-bind="scope.attr"
  192. v-model="scope.row[scope.item.key]"
  193. :size="$attrs.size"
  194. :source.sync="scope.row"
  195. :disabled="!isEdit || scope.row.status !== '1'"
  196. >
  197. <el-option
  198. v-for="item in dict.type[scope.attr.dictName]"
  199. :key="item.value"
  200. :label="item.label"
  201. :value="item.value"
  202. >
  203. </el-option>
  204. </component>
  205. </template>
  206. <!-- 补单标识-->
  207. <template slot="isReplenishment" slot-scope="scope">
  208. <component
  209. v-bind="scope.attr"
  210. v-model="scope.row[scope.item.key]"
  211. :size="$attrs.size"
  212. :source.sync="scope.row"
  213. :disabled="!isEdit || scope.row.status !== '1'"
  214. @change="(val) => changeReplenishment(val, scope.row)"
  215. >
  216. <el-option
  217. v-for="item in dict.type[scope.attr.dictName]"
  218. :key="item.value"
  219. :label="item.label"
  220. :value="item.value"
  221. >
  222. </el-option>
  223. </component>
  224. </template>
  225. <!-- 收货仓库-->
  226. <template slot="deliveryWarehouseName" slot-scope="scope">
  227. <component
  228. v-bind="scope.attr"
  229. v-model="scope.row[scope.item.key]"
  230. :size="$attrs.size"
  231. :source.sync="scope.row"
  232. :disabled="!isEdit || scope.row.status !== '1'"
  233. >
  234. </component>
  235. </template>
  236. <!-- 收货货位-->
  237. <template slot="deliveryAllocationName" slot-scope="scope">
  238. <component
  239. v-bind="scope.attr"
  240. v-model="scope.row[scope.item.key]"
  241. :size="$attrs.size"
  242. :source.sync="scope.row"
  243. :disabled="!isEdit || scope.row.status !== '1'"
  244. >
  245. </component>
  246. </template>
  247. <!-- 补单供应商-->
  248. <template slot="additionalSupplierName" slot-scope="scope">
  249. <component
  250. v-bind="scope.attr"
  251. v-model="scope.row[scope.item.key]"
  252. :size="$attrs.size"
  253. :source.sync="scope.row"
  254. :disabled="
  255. !isEdit ||
  256. scope.row.status !== '1' ||
  257. (isEdit && scope.row.isReplenishment === 'N')
  258. "
  259. >
  260. </component>
  261. </template>
  262. <!-- 采购组织-->
  263. <template slot="orgName" slot-scope="scope">
  264. <component
  265. v-bind="scope.attr"
  266. v-model="scope.row[scope.item.key]"
  267. :size="$attrs.size"
  268. :source.sync="scope.row"
  269. :disabled="!isEdit || scope.row.status !== '1'"
  270. >
  271. </component>
  272. </template>
  273. </el-super-ux-table>
  274. </el-drawer>
  275. </template>
  276. <style scoped>
  277. .el-button-group + .el-button-group {
  278. margin: 0 0 0 8px;
  279. }
  280. >>> .el-drawer__header {
  281. margin-bottom: 0;
  282. padding: 5px 20px;
  283. }
  284. </style>