main.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="出口价格库"
  5. class="el-dialogDeep"
  6. :visible.sync="visible"
  7. top="5vh"
  8. width="80%"
  9. append-to-body
  10. @closed="closed"
  11. :close-on-click-modal="false"
  12. v-dialog-drag
  13. >
  14. <span>
  15. <el-row>
  16. <el-col :span="4">
  17. <avue-tree
  18. :option="treeOption"
  19. @node-click="nodeClick"
  20. style="height:74vh"
  21. />
  22. </el-col>
  23. <el-col :span="20">
  24. <avue-crud
  25. ref="crud"
  26. :data="data"
  27. :option="tableOption"
  28. :page.sync="page"
  29. :search.sync="search"
  30. @search-change="searchChange"
  31. @current-change="currentChange"
  32. @size-change="sizeChange"
  33. @refresh-change="refreshChange"
  34. @on-load="getList"
  35. @saveColumn="saveColumn"
  36. @selection-change="selectionChange"
  37. :cell-style="cellStyle"
  38. :table-loading="loading"
  39. >
  40. <template slot="cnameSearch">
  41. <goods-select
  42. v-model="search.cname"
  43. :configuration="goodsConfiguration"
  44. />
  45. </template>
  46. <template slot="corpCodeSearch">
  47. <crop-select
  48. v-model="search.corpId"
  49. gysType="CK"
  50. corpType="GYS"
  51. ></crop-select>
  52. </template>
  53. </avue-crud>
  54. </el-col>
  55. </el-row>
  56. </span>
  57. <span slot="footer" class="dialog-footer">
  58. <el-button @click="visible = false">取 消</el-button>
  59. <el-button
  60. type="primary"
  61. @click="importData"
  62. :disabled="selectionList.length == 0"
  63. >导 入</el-button
  64. >
  65. </span>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import option from "./configuration/mainList.json";
  71. import {
  72. getPricebank,
  73. getGoodstype,
  74. getDeptLazyTree
  75. } from "@/api/basicData/customerInquiry";
  76. import { dateFormat } from "@/util/date";
  77. import _ from "lodash";
  78. export default {
  79. data() {
  80. return {
  81. treeForm: {},
  82. treeOption: {
  83. nodeKey: "id",
  84. lazy: true,
  85. treeLoad: function(node, resolve) {
  86. const parentId = node.level === 0 ? 0 : node.data.id;
  87. getDeptLazyTree(parentId).then(res => {
  88. resolve(
  89. res.data.data.map(item => {
  90. return {
  91. ...item,
  92. leaf: !item.hasChildren
  93. };
  94. })
  95. );
  96. });
  97. },
  98. addBtn: false,
  99. menu: false,
  100. size: "small",
  101. props: {
  102. label: "title",
  103. value: "value",
  104. children: "children"
  105. }
  106. },
  107. visible: false,
  108. loading: true,
  109. data: [],
  110. search: {},
  111. tableOption: option,
  112. height: window.innerHeight - 500,
  113. page: {
  114. currentPage: 1,
  115. total: 0,
  116. pageSize: 10
  117. },
  118. selectionList: [],
  119. goodsConfiguration: {
  120. multipleChoices: false,
  121. multiple: false,
  122. collapseTags: false,
  123. placeholder: "请点击右边按钮选择",
  124. dicData: [],
  125. clearable: true
  126. },
  127. partType: false,
  128. partreData: false
  129. };
  130. },
  131. props: {},
  132. filters: {},
  133. created() {
  134. getGoodstype(1, 500).then(res => {
  135. this.findObject(this.tableOption.column, "goodsTypeName").dicData =
  136. res.data.data.records;
  137. // this.treeData = res.data.data.records;
  138. });
  139. if (localStorage.getItem("roleName").indexOf('贸易') == -1 && localStorage.getItem("roleName").indexOf('运营') == -1) {
  140. this.findObject(this.tableOption.column, "purchaseAmount").hide = false;
  141. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = true;
  142. this.findObject(this.tableOption.column, "taxRate").hide = false;
  143. this.findObject(this.tableOption.column, "taxRate").showColumn = true;
  144. this.findObject(this.tableOption.column, "price").hide = false;
  145. this.findObject(this.tableOption.column, "price").showColumn = true;
  146. }else {
  147. this.findObject(this.tableOption.column, "purchaseAmount").hide = true;
  148. this.findObject(this.tableOption.column, "purchaseAmount").showColumn = false;
  149. this.findObject(this.tableOption.column, "taxRate").hide = true;
  150. this.findObject(this.tableOption.column, "taxRate").showColumn = false;
  151. this.findObject(this.tableOption.column, "price").hide = true;
  152. this.findObject(this.tableOption.column, "price").showColumn = false;
  153. }
  154. },
  155. methods: {
  156. init(status, partreData) {
  157. this.partType = status;
  158. this.partreData = partreData;
  159. this.visible = true;
  160. this.getList(this.page, this.search);
  161. },
  162. cellStyle() {
  163. return "padding:0;height:40px;";
  164. },
  165. nodeClick(data) {
  166. console.log(data);
  167. this.search.goodTypeId = data.value;
  168. this.getList(this.page, this.search);
  169. },
  170. importData() {
  171. if (this.partreData) {
  172. if (this.selectionList.length != 1) {
  173. return this.$message.error("重新选择的时候只能选择一条数据");
  174. }
  175. }
  176. this.visible = false;
  177. if (this.partType) {
  178. this.$emit("librayToPart", this.selectionList, this.partreData);
  179. } else {
  180. this.$emit("importLibray", this.selectionList);
  181. }
  182. },
  183. currentChange(val) {
  184. this.page.currentPage = val;
  185. },
  186. sizeChange(val) {
  187. this.page.currentPage = 1;
  188. this.page.pageSize = val;
  189. },
  190. //点击搜索按钮触发
  191. searchChange(params, done) {
  192. this.search = this.deepClone(params);
  193. this.getList(this.page, params);
  194. done();
  195. },
  196. refreshChange() {
  197. this.getList(this.page, this.search);
  198. },
  199. getList(page, params) {
  200. let data = {
  201. ...params,
  202. billType: "CG",
  203. statusTime: dateFormat(new Date(), "yyyy-MM-dd")
  204. };
  205. let obj = Object.assign(data, this.search);
  206. this.loading = true;
  207. getPricebank(page.currentPage, page.pageSize, obj)
  208. .then(res => {
  209. this.data = res.data.data.records ? res.data.data.records : [];
  210. this.page.total = res.data.data.total;
  211. if (this.page.total > 0) {
  212. this.tableOption.height = window.innerHeight - 350;
  213. }
  214. })
  215. .finally(() => {
  216. this.loading = false;
  217. });
  218. },
  219. selectionChange(list) {
  220. this.selectionList = list;
  221. },
  222. closed() {
  223. this.partreData = null;
  224. this.$refs.crud.toggleSelection();
  225. }
  226. }
  227. };
  228. </script>
  229. <style scoped lang="scss"></style>