main.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div>
  3. <el-dialog title="配件库" class="el-dialogDeep" :visible.sync="visible" top="5vh" width="80%" append-to-body
  4. @closed="closed" :close-on-click-modal="false" v-dialog-drag>
  5. <span>
  6. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  7. <el-tab-pane label="选择配件价格库" name="first">
  8. <avue-crud ref="crud" :data="data" :option="tableOption" :page.sync="page" :search.sync="search"
  9. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  10. @refresh-change="refreshChange" @on-load="getList" @saveColumn="saveColumn"
  11. @selection-change="selectionChange" :cell-style="cellStyle" :table-loading="loading">
  12. <template slot="corpCodeSearch">
  13. <crop-select v-model="search.corpId" gysType="CK" corpType="GYS"></crop-select>
  14. </template>
  15. <template slot="menuLeft">
  16. <el-button type="primary" size="small" @click.stop="addRow" :disabled="selectionList.length==0">批量选择
  17. </el-button>
  18. </template>
  19. </avue-crud>
  20. </el-tab-pane>
  21. <el-tab-pane label="已选择价格库" name="second">
  22. <avue-crud ref="crud2" :data="pickData" :option="tableOption2" @refresh-change="refreshChange"
  23. :summary-method="summaryMethod" :cell-style="cellStyle">
  24. <template slot="goodNumber" slot-scope="{ row }">
  25. <el-input v-model="row.goodNumber" size="small" @change="priceChange(row)"></el-input>
  26. </template>
  27. <template slot="menu" slot-scope="{ row, index }">
  28. <el-button type="text" size="small" @click.stop="rowDel(row, index)" icon="el-icon-delete">删除
  29. </el-button>
  30. </template>
  31. </avue-crud>
  32. </el-tab-pane>
  33. </el-tabs>
  34. </span>
  35. <span slot="footer" class="dialog-footer">
  36. <el-button @click="visible = false">取 消</el-button>
  37. <el-button type="primary" @click="importData" :disabled="pickData.length == 0">确 定</el-button>
  38. </span>
  39. </el-dialog>
  40. </div>
  41. </template>
  42. <script>
  43. import option from "./configuration/mainList.json";
  44. import tableOption2 from "./configuration/mainList2.json";
  45. import {
  46. getPricebank,
  47. getPartTree,
  48. getGoodstype
  49. } from "@/api/basicData/customerInquiry";
  50. import { dateFormat } from "@/util/date";
  51. import { costCal } from "@/util/calculate";
  52. import _ from "lodash";
  53. import { Switch } from "element-ui";
  54. export default {
  55. data() {
  56. return {
  57. activeName: 'first',
  58. visible: false,
  59. loading: true,
  60. data: [],
  61. search: {},
  62. tableOption: option,
  63. height: window.innerHeight - 500,
  64. page: {
  65. currentPage: 1,
  66. total: 0,
  67. pageSize: 10
  68. },
  69. selectionList: [],
  70. partType: null,
  71. pickData: [],
  72. tableOption2: tableOption2,
  73. };
  74. },
  75. props: {},
  76. filters: {},
  77. created() {
  78. if (localStorage.getItem("roleName") == "贸易") {
  79. this.findObject(this.tableOption.column, "taxRate").hide = true;
  80. this.findObject(this.tableOption.column, "taxRate").showColumn = false;
  81. this.findObject(this.tableOption.column, "price").hide = true;
  82. this.findObject(this.tableOption.column, "price").showColumn = false;
  83. }
  84. },
  85. methods: {
  86. init(status, partData) {
  87. this.partType = status;
  88. this.pickData = partData ? JSON.parse(partData) : []
  89. this.visible = true;
  90. this.getList(this.page, this.search);
  91. },
  92. addRow() {
  93. this.selectionList.forEach(e => {
  94. this.pickData.push({
  95. goodId: e.itemId,
  96. goodTypeId: e.goodTypeId,
  97. goodTypeName: e.goodsTypeName,
  98. ename: e.ename,
  99. corpId: e.corpId,
  100. corpName: e.corpCode,
  101. goodName: e.ename,
  102. price: e.purchaseAmount,
  103. goodNumber: 1,
  104. amout: e.purchaseAmount,
  105. partsCost: costCal(e.price, e.taxRate)
  106. });
  107. });
  108. this.$refs.crud.toggleSelection();
  109. },
  110. rowDel(row, index) {
  111. this.$confirm("确定删除数据?", {
  112. confirmButtonText: "确定",
  113. cancelButtonText: "取消",
  114. type: "warning"
  115. }).then(() => {
  116. this.$message({
  117. type: "success",
  118. message: "删除成功!"
  119. });
  120. this.pickData.splice(index, 1);
  121. });
  122. },
  123. cellStyle() {
  124. return "padding:0;height:40px;";
  125. },
  126. handleClick(tab, event) {
  127. console.log(tab, event);
  128. },
  129. currentChange(val) {
  130. this.page.currentPage = val;
  131. },
  132. sizeChange(val) {
  133. this.page.currentPage = 1;
  134. this.page.pageSize = val;
  135. },
  136. //点击搜索按钮触发
  137. searchChange(params, done) {
  138. this.search = this.deepClone(params);
  139. this.getList(this.page, params);
  140. done();
  141. },
  142. refreshChange() {
  143. this.getList(this.page, this.search);
  144. },
  145. getgoodsTypeName(val) {
  146. let name = null
  147. switch (val) {
  148. case 0:
  149. name = '阀门配件'
  150. break;
  151. case 1:
  152. name = '瓶帽配件'
  153. break;
  154. case 2:
  155. name = '特殊处理'
  156. break;
  157. case 3:
  158. name = '包装方式'
  159. break;
  160. case 4:
  161. name = '特殊颜色'
  162. break;
  163. case 5:
  164. name = '认证'
  165. break;
  166. case 6:
  167. name = '其他'
  168. break;
  169. }
  170. return name
  171. },
  172. getList(page, params) {
  173. let data = {
  174. ...params,
  175. billType: "CG",
  176. goodsTypeName:this.getgoodsTypeName(this.partType),
  177. statusTime: dateFormat(new Date(), "yyyy-MM-dd")
  178. };
  179. let obj = Object.assign(data, this.search);
  180. this.loading = true;
  181. getPricebank(page.currentPage, page.pageSize, obj)
  182. .then(res => {
  183. this.data = res.data.data.records ? res.data.data.records : [];
  184. this.page.total = res.data.data.total;
  185. if (this.page.total > 0) {
  186. this.tableOption.height = window.innerHeight - 350;
  187. }
  188. })
  189. .finally(() => {
  190. this.loading = false;
  191. });
  192. },
  193. selectionChange(list) {
  194. this.selectionList = list;
  195. },
  196. priceChange(row) {
  197. row.amout = _.multiply(row.price, row.goodNumber)
  198. },
  199. importData() {
  200. this.$emit("importPart", this.pickData, this.partType);
  201. this.visible = false;
  202. },
  203. closed() {
  204. this.pickData = null;
  205. this.activeName = 'first';
  206. this.pickData = [];
  207. this.$refs.crud.toggleSelection();
  208. }
  209. },
  210. watch: {
  211. }
  212. };
  213. </script>
  214. <style scoped lang="scss">
  215. </style>