index.vue 8.9 KB

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