index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div>
  3. <basic-container v-if="show">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="data"
  8. :page.sync="page"
  9. @search-change="searchChange"
  10. :search.sync="search"
  11. :table-loading="loading"
  12. @on-load="onLoad"
  13. @row-update="rowUpdate"
  14. :cell-style="cellStyle">
  15. <template slot-scope="scope" slot="lockingQuantity">
  16. <span v-if="Number(scope.row.lockingQuantity) > 0" style="color: #409EFF;cursor: pointer" @click.stop="viewCell(scope.row,scope.index)">{{ scope.row.lockingQuantity }}</span>
  17. <span v-else>{{ scope.row.lockingQuantity }}</span>
  18. </template>
  19. <template slot-scope="{row,index}" slot="menu">
  20. <el-button
  21. type="text"
  22. size="small"
  23. @click="rowCell(row,index)"
  24. >{{ row.$cellEdit ? '保存' : '修改' }}
  25. </el-button>
  26. <el-button
  27. type="text"
  28. size="small"
  29. @click="deletePrice(row,index)"
  30. >删除
  31. </el-button>
  32. </template>
  33. <template slot="menuLeft">
  34. <el-button
  35. type="primary"
  36. size="small"
  37. icon="el-icon-plus"
  38. @click="excelBox = !excelBox"
  39. >导入
  40. </el-button>
  41. <el-button
  42. type="success"
  43. icon="el-icon-download"
  44. size="small"
  45. @click="derivation()"
  46. >下载模板
  47. </el-button>
  48. <el-button
  49. type="info"
  50. icon="el-icon-printer"
  51. size="small"
  52. :loading="exportLoading"
  53. @click.stop="statement"
  54. >报 表
  55. </el-button>
  56. </template>
  57. </avue-crud>
  58. <el-dialog title="导入价格"
  59. append-to-body
  60. :visible.sync="excelBox"
  61. :close-on-click-modal="false"
  62. width="555px">
  63. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"/>
  64. </el-dialog>
  65. </basic-container>
  66. <report-dialog
  67. :switchDialog="switchDialog"
  68. :searchValue="statementData"
  69. :reportName="'国内贸易-库存账'"
  70. @onClose="onClose()"
  71. ></report-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import option from "./configuration/mainList.json"
  76. import {deleteTemplate,customerList,typeSave} from "@/api/basicData/inventoryAccount"
  77. import {getToken} from "@/util/auth";
  78. import { defaultDate } from "@/util/date";
  79. import reportDialog from "@/components/report-dialog/main";
  80. export default {
  81. components:{
  82. reportDialog
  83. },
  84. data() {
  85. return {
  86. data: [],
  87. search:{},
  88. loading: false,
  89. exportLoading:false,
  90. switchDialog:false,
  91. statementData: {},
  92. excelForm: {},
  93. excelOption: {
  94. submitBtn: false,
  95. emptyBtn: false,
  96. column: [
  97. {
  98. label: '导入数据',
  99. prop: 'excelFile',
  100. type: 'upload',
  101. drag: true,
  102. loadText: '导入数据中,请稍等',
  103. span: 24,
  104. propsHttp: {
  105. res: 'data'
  106. },
  107. tip: '请上传 .xls,.xlsx 标准格式文件',
  108. action: "/api/blade-stock/stockgoods/import-price"
  109. }
  110. ]
  111. },
  112. excelBox: false,
  113. option: option,
  114. page: {
  115. pageSize: 10,
  116. pagerCount: 5,
  117. total: 0,
  118. pageSizes: [10,50,100,200,300]
  119. },
  120. show: true,
  121. params: {
  122. corpId: null,
  123. itemId: null
  124. },
  125. }
  126. },
  127. created() {
  128. this.search.createTime = defaultDate(1)
  129. let i = 0;
  130. this.option.column.forEach(item => {
  131. if (item.search) i++
  132. })
  133. if (i % 3 !== 0){
  134. const num = 3 - Number(i % 3)
  135. this.option.searchMenuSpan = num * 8;
  136. this.option.searchMenuPosition = "right";
  137. }
  138. },
  139. methods: {
  140. cellStyle() {
  141. return "padding:0;height:40px;";
  142. },
  143. derivation() {
  144. this.$confirm("是否下载模板?", "提示", {
  145. confirmButtonText: "确定",
  146. cancelButtonText: "取消",
  147. type: "warning"
  148. }).then(() => {
  149. window.open(`/api/blade-stock/stockgoods/export-template?${this.website.tokenHeader}=${getToken()}`);
  150. });
  151. },
  152. uploadAfter(res, done, loading, column) {
  153. console.log(res)
  154. window.console.log(column);
  155. this.excelBox = false;
  156. this.page.currentPage = 1;
  157. if (res) {
  158. this.$message.warning(res)
  159. } else {
  160. this.$message.success('导入成功')
  161. }
  162. this.onLoad(this.page);
  163. loading()
  164. done();
  165. },
  166. rowCell(row, index) {
  167. this.$refs.crud.rowCell(row, index)
  168. },
  169. deletePrice(row,index){
  170. if (row.id){
  171. this.$confirm("确定将选择数据删除?", {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning"
  175. }).then(() => {
  176. return deleteTemplate(row.id);
  177. }).then(() => {
  178. this.$message({
  179. type: "success",
  180. message: "操作成功!"
  181. });
  182. this.page.currentPage = 1;
  183. this.onLoad(this.page);
  184. })
  185. }
  186. },
  187. //点击搜索按钮触发
  188. searchChange(params, done) {
  189. if (params.createTime) {
  190. params.createStartTime = params.createTime[0]+ " " + "00:00:00"
  191. params.createEndTime = params.createTime[1]+ " " + "23:59:59"
  192. delete params.createTime;
  193. }
  194. this.page.currentPage = 1;
  195. this.onLoad(this.page, params);
  196. done()
  197. },
  198. onLoad(page, params = {}) {
  199. if (this.search.createTime && this.search.createTime.length > 0) {
  200. params = {
  201. ...params,
  202. createStartTime: this.search.createTime[0]+ " " + "00:00:00",
  203. createEndTime: this.search.createTime[1]+ " " + "23:59:59",
  204. }
  205. delete params.createTime;
  206. }
  207. let queryParams = Object.assign({}, params, {
  208. size: page.pageSize,
  209. current: page.currentPage,
  210. })
  211. this.loading = true;
  212. customerList(queryParams).then(res => {
  213. this.data = res.data.data.records
  214. this.page.total = res.data.data.total
  215. }).finally(() => {
  216. this.loading = false;
  217. })
  218. },
  219. rowUpdate(form, index, done) {
  220. typeSave(form).then(res => {
  221. this.$message({type: "success", message: form.id ? "修改成功!" : "新增成功!"});
  222. // this.page.currentPage = 1;
  223. // this.onLoad(this.page);
  224. //成功关闭此页面回到列表页
  225. // this.backToList()
  226. })
  227. done()
  228. },
  229. // 查看
  230. viewCell(row, index) {
  231. if (this.$store.getters.domStockDetail) {
  232. this.$alert("明细已存在,请保存关闭明细再进行操作", "温馨提示", {
  233. confirmButtonText: "确定",
  234. type: "warning",
  235. callback: action => {
  236. console.log(action);
  237. }
  238. });
  239. } else {
  240. this.params.corpId = row.corpId
  241. this.params.itemId = row.goodsId
  242. this.$router.$avueRouter.closeTag("/businessManagement/inventoryAccount/detail");
  243. this.$router.push({
  244. path: "/businessManagement/inventoryAccount/detail",
  245. query: {
  246. corpId: row.corpId,
  247. itemId: row.goodsId
  248. },
  249. });
  250. }
  251. // this.show = false;
  252. },
  253. statement() {
  254. this.statementData = {...this.search}
  255. this.statementData.createStartTime = this.statementData.createTime[0]+ " " + "00:00:00"
  256. this.statementData.createEndTime = this.statementData.createTime[1]+ " " + "23:59:59"
  257. delete this.statementData.createTime
  258. this.switchDialog = !this.switchDialog;
  259. },
  260. onClose(val) {
  261. this.switchDialog = val;
  262. },
  263. }
  264. }
  265. </script>