payGoodsInfo.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="teamCourseList">
  3. <p class="coreTitle" style="margin-top: 0">商品采购</p>
  4. <div style="padding: 10px 20px">
  5. <el-table
  6. class="courseTable"
  7. :data="form.calenderGoodsList"
  8. style="width: 100% !important; background: #f9f9f9;"
  9. :header-cell-style="{ background: '#F9F9F9', color: '#444' }"
  10. >
  11. <el-table-column width="170px" label="商品名称">
  12. <template slot-scope="scope">
  13. <tooltip :content="scope.row.goodsName" />
  14. </template>
  15. </el-table-column>
  16. <el-table-column width="170px" label="商品货号" prop="goodsSn">
  17. </el-table-column>
  18. <el-table-column width="170px" label="采购价格" prop="singlePrice">
  19. <template slot-scope="scope">
  20. {{ scope.row.singlePrice | moneyFormat }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column width="170px" label="采购数量">
  24. <template slot-scope="scope">
  25. <el-form-item
  26. :prop="'calenderGoodsList.' + scope.$index + '.num'"
  27. :rules="{
  28. required: true,
  29. message: '请输入采购数量',
  30. trigger: 'change'
  31. }"
  32. >
  33. <el-input-number
  34. style="width: 90% !important"
  35. class="number-input"
  36. v-model="form.calenderGoodsList[scope.$index].num"
  37. :controls="false"
  38. :precision="0"
  39. :min="0"
  40. placeholder="请输入采购数量"
  41. @change="onChangeNum(scope.$index)"
  42. />
  43. </el-form-item>
  44. </template>
  45. </el-table-column>
  46. <el-table-column width="170px" label="总价格" prop="totalPrice">
  47. <template slot-scope="scope">
  48. {{ scope.row.totalPrice | moneyFormat }}
  49. </template>
  50. </el-table-column>
  51. <el-table-column width="170px" label="操作">
  52. <template slot-scope="scope">
  53. <el-button type="text" @click.prevent="removeGoodsList(scope.row)"
  54. >删除</el-button
  55. >
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <el-button
  60. icon="el-icon-circle-plus-outline"
  61. plain
  62. type="info"
  63. style="width: 100%;margin: 10px 0 10px;"
  64. @click="addGoodsList"
  65. >添加商品</el-button
  66. >
  67. </div>
  68. <el-dialog
  69. title="添加商品"
  70. :visible.sync="recordStatus"
  71. :close-on-click-modal="false"
  72. width="1200px"
  73. append-to-body
  74. v-if="recordStatus"
  75. >
  76. <addShopGoods
  77. :courseViewType="courseViewType"
  78. :organId="organId"
  79. :disabledIds="disabledIds"
  80. @close="recordStatus = false"
  81. @confirm="onConfirm"
  82. :categoryList="categoryList"
  83. :goodsBrand="goodsBrand"
  84. />
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import {
  90. api_queryGoodsCategoryList,
  91. api_queryGoodsBrandList
  92. } from "@/api/businessManager";
  93. import addShopGoods from "./addShopGoods";
  94. export default {
  95. components: {
  96. addShopGoods
  97. },
  98. props: ["form", "courseViewType", "organId"],
  99. data() {
  100. return {
  101. disabledIds: [],
  102. recordStatus: false,
  103. categoryList: [],
  104. goodsBrand: []
  105. };
  106. },
  107. mounted() {
  108. this.getCategory();
  109. this.getGoodsBrand();
  110. },
  111. methods: {
  112. removeGoodsList(item) {
  113. const index = this.form.calenderGoodsList.indexOf(item);
  114. if (index !== -1) {
  115. this.form.calenderGoodsList.splice(index, 1);
  116. }
  117. },
  118. onChangeNum(index) {
  119. const form = this.form.calenderGoodsList[index];
  120. this.form.calenderGoodsList[index].totalPrice =
  121. Number(form.singlePrice) * Number(form.num);
  122. },
  123. /** 商品分类 */
  124. async getCategory() {
  125. let params = {
  126. // delFlag: 0,
  127. rows: 9999
  128. };
  129. try {
  130. const { data } = await api_queryGoodsCategoryList(params);
  131. console.log(data, "data");
  132. const result = data || [];
  133. let tempArray = [];
  134. result.forEach(row => {
  135. tempArray.push({
  136. label: row.name,
  137. value: row.id
  138. });
  139. });
  140. this.categoryList = tempArray;
  141. } catch {}
  142. },
  143. /** 商品品牌 */
  144. async getGoodsBrand() {
  145. try {
  146. const { data } = await api_queryGoodsBrandList({ rows: 999 });
  147. const result = data || [];
  148. let tempArray = [];
  149. result.forEach(row => {
  150. tempArray.push({
  151. label: row.name,
  152. value: row.id
  153. });
  154. });
  155. this.goodsBrand = tempArray;
  156. } catch {}
  157. },
  158. async addGoodsList() {
  159. // 添加商品
  160. const ids = [];
  161. this.form.calenderGoodsList.forEach(goods => {
  162. ids.push(goods.id);
  163. });
  164. this.disabledIds = ids;
  165. this.recordStatus = true;
  166. },
  167. onConfirm(list) {
  168. const goodsList = [];
  169. console.log(list, this.form.calenderGoodsList, "list");
  170. (list || []).forEach(item => {
  171. const index = this.form.calenderGoodsList.findIndex(
  172. goods => goods.id == item.id
  173. );
  174. if (index == -1) {
  175. goodsList.push({
  176. id: item.id,
  177. goodsName: item.name,
  178. goodsId: item.id,
  179. goodsSn: item.sn,
  180. num: 0,
  181. singlePrice: item.discountPrice,
  182. totalPrice: 0
  183. });
  184. }
  185. });
  186. this.form.calenderGoodsList.push(...goodsList);
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. @import "~@/views/resetTeaming/modals/pay.scss";
  193. ::v-deep .infoWrap {
  194. padding: 10px;
  195. .el-form-item__label {
  196. display: block !important;
  197. text-align: left;
  198. padding-left: 10px;
  199. }
  200. .vertical {
  201. margin-top: 0px !important;
  202. }
  203. .el-input-number {
  204. width: 180px;
  205. .el-input__inner {
  206. text-align: left;
  207. }
  208. }
  209. }
  210. .number-input {
  211. ::v-deep .el-input__inner {
  212. text-align: left;
  213. }
  214. width: 100%;
  215. }
  216. .memoWrap {
  217. width: 860px;
  218. .memoWrapItem {
  219. display: block;
  220. ::v-deep .el-form-item__content {
  221. display: inline-block;
  222. width: calc(100% - 140px);
  223. }
  224. }
  225. }
  226. </style>