index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <script>
  2. import { TableColumns } from "./column";
  3. import { FIRSTDIRECT, ADD } from "@/api/business/purchase/task";
  4. export default {
  5. name: "FirstDirectPurchaseDrawer",
  6. components: {},
  7. data() {
  8. return {
  9. size: "mini",
  10. title: "协议直采",
  11. width: "100%",
  12. column: 3,
  13. visible: false,
  14. loading: false,
  15. tableColumns: TableColumns,
  16. data: [],
  17. };
  18. },
  19. computed: {
  20. $dicts: {
  21. get: function () {
  22. return this.$parent.$parent.$dicts;
  23. },
  24. },
  25. },
  26. watch: {},
  27. methods: {
  28. //
  29. async open(prop) {
  30. this.visible = await this.fetchItem(prop);
  31. },
  32. //
  33. hide() {
  34. this.visible = false;
  35. },
  36. //
  37. async fetchItem(prop) {
  38. try {
  39. // try
  40. this.loading = true;
  41. const { code, data } = await FIRSTDIRECT(prop);
  42. if (code === 200) {
  43. this.data = data.map((item) => ({
  44. ...item,
  45. orderPriceVos: item.orderPriceVos.map((cItem) => ({
  46. ...item,
  47. ...cItem,
  48. })),
  49. }));
  50. console.log("this.data", this.data);
  51. return true;
  52. } else {
  53. return false;
  54. }
  55. } catch (err) {
  56. // catch
  57. console.error(err);
  58. } finally {
  59. // finally
  60. this.loading = false;
  61. }
  62. },
  63. //
  64. async submit(prop) {
  65. const params = prop
  66. .map((item) => ({
  67. ...item,
  68. orderPriceVos: item.orderPriceVos.filter(
  69. (citem) => citem.purchaseQuantity
  70. ),
  71. }))
  72. .filter((item) => item.orderPriceVos.length);
  73. try {
  74. // try
  75. const { msg, code } = await ADD(params);
  76. if (code === 200) {
  77. this.hide();
  78. this.$emit("success");
  79. this.$notify.success({ title: msg, duration: 3000 });
  80. }
  81. } catch (err) {
  82. // catch
  83. } finally {
  84. // finally
  85. }
  86. },
  87. },
  88. created() {},
  89. mounted() {},
  90. destroyed() {},
  91. };
  92. </script>
  93. <template>
  94. <el-drawer
  95. :size="width"
  96. :title="title"
  97. :show-close="false"
  98. :visible.sync="visible"
  99. >
  100. <template slot="title">
  101. <span>{{ title }}</span>
  102. <span>
  103. <el-button
  104. :size="size"
  105. circle
  106. icon="el-icon-check"
  107. @click="submit(data)"
  108. >
  109. </el-button>
  110. <el-button
  111. :size="size"
  112. circle
  113. type="danger"
  114. icon="el-icon-close"
  115. @click="visible = false"
  116. ></el-button>
  117. </span>
  118. </template>
  119. <div v-for="(item, index) in data" :key="index" style="margin: 10px">
  120. <el-descriptions :size="size" :column="column" border>
  121. <template #title>
  122. <span style="margin-right: 10px">{{ item.materialName }}</span>
  123. <span style="color: tomato">{{ item.puQty }}</span>
  124. (<span style="color: tomato">{{
  125. item.puQty - (item.executeQty || 0)
  126. }}</span
  127. >)
  128. <span> {{ item.puUnitName }}</span>
  129. </template>
  130. <el-descriptions-item label="需求组织">
  131. {{ item.demandOrgName }}
  132. </el-descriptions-item>
  133. <el-descriptions-item label="采购组织">
  134. {{ item.puOrgName }}
  135. </el-descriptions-item>
  136. <el-descriptions-item label="需求时间">
  137. {{ item.demandDate }}
  138. </el-descriptions-item>
  139. </el-descriptions>
  140. <el-table
  141. v-loading="loading"
  142. :size="size"
  143. :data="item.orderPriceVos"
  144. style="width: 100%"
  145. >
  146. <el-table-column
  147. v-for="(cItem, cIndex) in tableColumns"
  148. :key="cIndex"
  149. :prop="cItem.item.key"
  150. :label="cItem.item.title"
  151. :fixed="cItem.item.fixed"
  152. :width="cItem.item.width || 250"
  153. show-overflow-tooltip
  154. >
  155. <template slot-scope="scope">
  156. <el-input-number
  157. v-if="cItem.attr.component === 'el-input-number'"
  158. v-model="scope.row[cItem.item.key]"
  159. :size="size"
  160. :min="cItem.attr.min(item)"
  161. :max="cItem.attr.max(item)"
  162. :controls-position="cItem.attr.controlsPosition"
  163. style="width: 90%"
  164. ></el-input-number>
  165. <el-date-picker
  166. v-else-if="cItem.attr.component === 'el-date-picker'"
  167. v-model="scope.row[cItem.item.key]"
  168. :size="size"
  169. :type="cItem.attr.type"
  170. :value-format="cItem.attr.valueFormat"
  171. :picker-options="cItem.attr.pickerOptions"
  172. style="width: 90%"
  173. ></el-date-picker>
  174. <el-input
  175. v-else-if="cItem.attr.component === 'el-input'"
  176. v-model="scope.row[cItem.item.key]"
  177. :size="size"
  178. autosize
  179. type="textarea"
  180. style="width: 90%"
  181. ></el-input>
  182. <dr-computed-input
  183. v-else-if="cItem.attr.component === 'dr-computed-input'"
  184. v-model="scope.row[cItem.item.key]"
  185. :source="scope.row"
  186. :formatter="cItem.attr.formatter"
  187. style="width: 100%"
  188. ></dr-computed-input>
  189. <dict-tag
  190. v-else-if="cItem.attr.component === 'dict-tag'"
  191. :size="size"
  192. :value="scope.row[cItem.item.key]"
  193. :options="$dicts[cItem.attr.dictName]"
  194. />
  195. <span v-else>{{ scope.row[cItem.item.key] }}</span>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. </div>
  200. </el-drawer>
  201. </template>
  202. <style scoped></style>