index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <script>
  2. import { TableColumns ,BasicColumns} from "./column";
  3. import { initDicts } from "@/utils/init.js";
  4. import { FIRSTDIRECT, ADD } from "@/api/business/purchase/task";
  5. export default {
  6. name: "FirstDirectPurchaseDrawer",
  7. dicts: [...initDicts(TableColumns)],
  8. props: {
  9. selectData: {
  10. type: [Array],
  11. require: true,
  12. },
  13. },
  14. components: {
  15. ElSuperTable: () => import("@/components/super-table/index.vue"),
  16. ElDictTag: () => import("@/components/DictTag/index.vue"),
  17. ElComputedInputV2: () => import("@/components/computed-input-v2/index.vue"),
  18. },
  19. data() {
  20. return {
  21. title: "订单生成",
  22. width: "100%",
  23. column: 1,
  24. visible: false,
  25. loading: false,
  26. tableColumns: TableColumns,
  27. basicColumns:BasicColumns,
  28. data: [],
  29. };
  30. },
  31. computed: {
  32. disabled: {
  33. get() {
  34. return !this.selectData.length;
  35. },
  36. set() {},
  37. },
  38. supplierNameSelect:{
  39. get(){
  40. return
  41. },
  42. set(value){
  43. }
  44. }
  45. },
  46. watch: {},
  47. methods: {
  48. //
  49. async open(prop) {
  50. this.visible = await this.fetchItem(prop);
  51. },
  52. //
  53. hide() {
  54. this.visible = false;
  55. },
  56. //
  57. async fetchItem(prop) {
  58. try {
  59. // try
  60. this.loading = true;
  61. const { code, data } = await FIRSTDIRECT(prop);
  62. if (code === 200) {
  63. this.data = data.map((item) => ({
  64. ...item,
  65. orderPriceVos: item.orderPriceVos.map((cItem) => ({
  66. ...item,
  67. customerName:'',
  68. customer:'',
  69. ...cItem,
  70. purchaseQuantity: item.orderPriceVos.length === 1 ? (item.puQty - item.executeQty) : undefined
  71. })),
  72. }));
  73. console.log(this.data,'this.data');
  74. return true;
  75. } else {
  76. return false;
  77. }
  78. } catch (err) {
  79. // catch
  80. console.error(err);
  81. } finally {
  82. // finally
  83. this.loading = false;
  84. }
  85. },
  86. //
  87. async submit(prop) {
  88. const params = prop
  89. .map((item) => ({
  90. ...item,
  91. orderPriceVos: item.orderPriceVos.filter(
  92. (citem) => citem.purchaseQuantity
  93. ),
  94. }))
  95. .filter((item) => item.orderPriceVos.length);
  96. try {
  97. // try
  98. const { msg, code } = await ADD(params);
  99. if (code === 200) {
  100. this.hide();
  101. this.$emit("success");
  102. this.$notify.success({ title: msg, duration: 3000 });
  103. }
  104. } catch (err) {
  105. // catch
  106. } finally {
  107. // finally
  108. }
  109. },
  110. supplierChange(value){
  111. console.log(value,'value');
  112. },
  113. },
  114. created() {},
  115. mounted() {},
  116. destroyed() {},
  117. };
  118. </script>
  119. <template>
  120. <el-button
  121. v-bind="$attrs"
  122. v-on="$listeners"
  123. :disabled="disabled"
  124. @click="open(selectData)"
  125. >
  126. {{ title }}
  127. <el-drawer
  128. :show-close="false"
  129. :size="width"
  130. :title="title"
  131. :visible.sync="visible"
  132. append-to-body
  133. >
  134. <template slot="title">
  135. <span>{{ title }}</span>
  136. <el-button
  137. type="primary"
  138. :size="$attrs.size"
  139. :loading="loading"
  140. @click="submit(data)"
  141. >确 认</el-button
  142. >
  143. <el-button
  144. :size="$attrs.size"
  145. :loading="loading"
  146. @click="visible = false"
  147. >取 消</el-button
  148. >
  149. </template>
  150. <div v-for="(item, index) in data" :key="index" class="m-4">
  151. <el-descriptions>
  152. <template slot="title" >
  153. <template>
  154. <span style="margin-right: 10px">{{ item.materialName }}</span>
  155. <span style="color: tomato">{{ item.puQty }}</span>
  156. (<span style="color: tomato">{{
  157. item.puQty - (item.executeQty || 0)
  158. }}</span
  159. >) <span> {{ item.puUnitName }}</span>
  160. </template>
  161. </template>
  162. <el-descriptions-item
  163. v-for="(basic,bIndex) in basicColumns"
  164. :key="bIndex"
  165. :label="basic.item.title"
  166. >{{ item[basic.item.key] }}
  167. </el-descriptions-item>
  168. <el-descriptions-item
  169. label="需求数量"
  170. >{{ item.puQty - (item.executeQty || 0) }}
  171. </el-descriptions-item>
  172. </el-descriptions>
  173. <el-super-table
  174. v-model="item.orderPriceVos"
  175. :columns="tableColumns"
  176. :size="$attrs.size"
  177. :dict="dict"
  178. >
  179. <template slot="purchaseQuantity" slot-scope="scope">
  180. <component
  181. v-bind="scope.attr"
  182. v-model="scope.row[scope.item.key]"
  183. :size="$attrs.size"
  184. :max="scope.attr.max(scope.row)"
  185. >
  186. </component>
  187. </template>
  188. </el-super-table>
  189. </div>
  190. </el-drawer>
  191. </el-button>
  192. </template>
  193. <style scoped></style>