index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <!-- 搜索条件 -->
  5. <el-select
  6. v-model="getdataListParmImportInfo.parammaps.pastureName"
  7. placeholder="牧场"
  8. class="filter-item"
  9. style="width:110px"
  10. >
  11. <el-option
  12. v-for="item in findAllPasture"
  13. :key="item.id"
  14. :label="item.name"
  15. :value="item.name"
  16. />
  17. </el-select>
  18. <el-input
  19. v-model="getdataListParmImportInfo.parammaps.storageNumber"
  20. placeholder="入库单号"
  21. style="width: 110px;"
  22. class="filter-item"
  23. />
  24. <el-input
  25. v-model="getdataListParmImportInfo.parammaps.stockNumber"
  26. placeholder="备件编码"
  27. style="width: 110px;"
  28. class="filter-item"
  29. />
  30. <el-autocomplete
  31. v-model="temp.providerName"
  32. value-key="name"
  33. class="inline-input"
  34. :fetch-suggestions="providerSearch"
  35. placeholder="供应商"
  36. style="width:110px;top:-3px;"
  37. @select="handleSelect"
  38. />
  39. <el-date-picker
  40. v-model="getdataListParmImportInfo.parammaps.storageTime"
  41. type="date"
  42. placeholder="入库日期"
  43. style="width:140px;top:-3px;"
  44. format="yyyy-MM-dd"
  45. value-format="yyyy-MM-dd"
  46. />
  47. <el-button
  48. v-waves
  49. class="filter-item"
  50. type="primary"
  51. icon="el-icon-search"
  52. @click="form_search"
  53. >搜索</el-button>
  54. <div>
  55. <el-button
  56. v-if="isRetreatMuban"
  57. v-waves
  58. class="filter-item"
  59. type="info"
  60. icon="el-icon-download"
  61. @click="handleDownloadTemp"
  62. >模板</el-button>
  63. <el-upload
  64. style="display: inline-block;"
  65. :headers="headers"
  66. :data="uploadData"
  67. :action="uploadExcelUrl"
  68. :show-file-list="false"
  69. :before-upload="beforeImportExcel"
  70. :on-success="handleImportExcelSuccess"
  71. >
  72. <el-button
  73. v-if="isReceiveImport"
  74. v-waves
  75. class="filter-item"
  76. type="warning"
  77. icon="el-icon-upload2"
  78. >导入</el-button>
  79. </el-upload>
  80. <el-button
  81. style="position: absolute;"
  82. type="danger"
  83. @click="form_delete(selection)"
  84. >批量删除
  85. </el-button>
  86. </div>
  87. </div>
  88. <el-table
  89. :key="tableKey"
  90. v-loading="listLoadingImportInfo"
  91. element-loading-text="给我一点时间"
  92. :data="listImportInfo"
  93. border
  94. fit
  95. highlight-current-row
  96. style="width: 100%;"
  97. :row-style="rowStyle"
  98. :cell-style="cellStyle"
  99. class="elTable"
  100. @selection-change="handleSelectionChange"
  101. >
  102. <!-- table表格 -->
  103. <el-table-column
  104. type="selection"
  105. width="55"
  106. />
  107. <el-table-column label="序号" align="center" type="index" width="50px">
  108. <template slot-scope="scope">
  109. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="牧场" min-width="110px" align="center">
  113. <template slot-scope="scope">
  114. <span>{{ scope.row.pastureName }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="入库单编号" min-width="110px" align="center">
  118. <template slot-scope="scope">
  119. <span>{{ scope.row.storageNumber }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="入库时间" min-width="110px" align="center">
  123. <template slot-scope="scope">
  124. <span>{{ scope.row.storageTime }}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="物料编码" min-width="130px" align="center">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.stockNumber }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="品名" min-width="110px" align="center">
  133. <template slot-scope="scope">
  134. <span>{{ scope.row.stockName }}</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="规格型号" min-width="110px" align="center">
  138. <template slot-scope="scope">
  139. <span>{{ scope.row.specification }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="品牌" min-width="110px" align="center">
  143. <template slot-scope="scope">
  144. <span>{{ scope.row.trade }}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="计量单位" min-width="90px" align="center">
  148. <template slot-scope="scope">
  149. <span>{{ scope.row.unit }}</span>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="数量" min-width="70px" align="center">
  153. <template slot-scope="scope">
  154. <span>{{ scope.row.amount }}</span>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="单价" min-width="90px" align="center">
  158. <template slot-scope="scope">
  159. <span>{{ scope.row.price }}</span>
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="总价" min-width="90px" align="center">
  163. <template slot-scope="scope">
  164. <span>{{ scope.row.sumPrice }}</span>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="库位" min-width="110px" align="center">
  168. <template slot-scope="scope">
  169. <span>{{ scope.row.location }}</span>
  170. </template>
  171. </el-table-column>
  172. <el-table-column label="供应商" min-width="110px" align="center">
  173. <template slot-scope="scope">
  174. <span>{{ scope.row.providerName }}</span>
  175. </template>
  176. </el-table-column>
  177. <el-table-column label="导入人" min-width="110px" align="center">
  178. <template slot-scope="scope">
  179. <span>{{ scope.row.inputName }}</span>
  180. </template>
  181. </el-table-column>
  182. </el-table>
  183. <!-- 分页 -->
  184. <pagination
  185. v-show="total>=0"
  186. :total="totalImportInfo"
  187. :page.sync="getdataListParmImportInfo.offset"
  188. :limit.sync="getdataListParmImportInfo.pagecount"
  189. @pagination="get_table_dataImportInfo"
  190. />
  191. <el-dialog
  192. :title="textMap[dialogStatusErro]"
  193. :visible.sync="dialogFormVisibleErro"
  194. :close-on-click-modal="false"
  195. >
  196. <div class="app-erro">
  197. <el-table
  198. :key="tableKey"
  199. v-loading="listLoadingErro"
  200. element-loading-text="给我一点时间"
  201. :data="listErro"
  202. border
  203. fit
  204. highlight-current-row
  205. style="width: 100%;"
  206. :row-style="rowStyle"
  207. :cell-style="cellStyle"
  208. class="elTable"
  209. >
  210. <!-- table表格 -->
  211. <el-table-column label="序号" align="center" type="index" min-width="50px">
  212. <template slot-scope="scope">
  213. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  214. </template>
  215. </el-table-column>
  216. <el-table-column label="错误信息" min-width="110px" align="center">
  217. <template slot-scope="scope">
  218. <span><b>错误行:</b>{{ scope.row.input }}</span><br><span><b>错误信息:</b>{{ scope.row.error_msg }}</span>
  219. </template>
  220. </el-table-column>
  221. </el-table>
  222. </div>
  223. </el-dialog>
  224. </div>
  225. </template>
  226. <script>
  227. // 引入
  228. import { GetDataByName, GetDataByNames, ExecDataByConfig } from '@/api/common'
  229. import waves from '@/directive/waves' // waves directive
  230. import { parseTime } from '@/utils/index.js'
  231. // eslint-disable-next-line no-unused-vars
  232. import { validateEMail } from '@/utils/validate.js'
  233. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  234. import { MessageBox } from 'element-ui'
  235. import Cookies from 'js-cookie'
  236. import { getToken } from '@/utils/auth'
  237. export default {
  238. name: 'Storage',
  239. components: { Pagination },
  240. directives: { waves },
  241. data() {
  242. return {
  243. totalImportInfo: 0,
  244. listLoadingImportInfo: true,
  245. listImportInfo: [],
  246. isReceiveImport: [],
  247. isRetreatMuban: [],
  248. isStorageAdd: [],
  249. isStorageExport: [],
  250. isStorageSee: [],
  251. isStorageUpdate: [],
  252. isStorageDelate: [],
  253. tableKey: 0,
  254. listLoadingErro: true,
  255. listErro: [],
  256. list: [],
  257. list2: [],
  258. total: 0,
  259. listLoading: true,
  260. requestParam: {
  261. name: 'insertAsset',
  262. offset: 0,
  263. pagecount: 0,
  264. parammaps: {}
  265. },
  266. postDataPramas: {
  267. },
  268. // 1-2:table&搜索传参
  269. getdataListParmImportInfo: {
  270. name: 'getImportStockLaidList',
  271. page: 1,
  272. offset: 1,
  273. pagecount: 10,
  274. returntype: 'Map',
  275. parammaps: {
  276. pastureName: Cookies.get('pasturename'),
  277. deptName: '',
  278. useForm: '',
  279. stockNumber: '',
  280. stockName: '',
  281. receiveTime: '',
  282. providerName: '',
  283. storageName: '',
  284. storageTime: ''
  285. }
  286. },
  287. getdataListParmUpdate: {
  288. name: 'getStockLaidList',
  289. page: 0,
  290. offset: 0,
  291. pagecount: 0,
  292. returntype: 'Map',
  293. parammaps: {
  294. bigId: ''
  295. }
  296. },
  297. getParmCreateLaidNumber: {
  298. name: 'createLaidNumber',
  299. page: 0,
  300. offset: 0,
  301. pagecount: 0,
  302. returntype: 'Map',
  303. parammaps: {
  304. pastureNumber: Cookies.get('pasturenumber')
  305. }
  306. },
  307. orderAAA: {
  308. orderNumber: '',
  309. pastureId: '',
  310. pastureName: '',
  311. providerId: '',
  312. provoderName: '',
  313. orderA: '',
  314. stockId: '',
  315. stockNumber: '',
  316. stockName: '',
  317. specification: '',
  318. amount: '',
  319. unit: '',
  320. puropse: '',
  321. TAG: ''
  322. },
  323. // 2-3:下拉框请求后数据加入[]
  324. findAllProvider: [],
  325. findAllAssetType: [],
  326. findAllPasture: [],
  327. findAllDepart: [],
  328. findAllEmploye: [],
  329. getDictByName: [],
  330. // 2-1.请求下拉框接口
  331. requestParams: [
  332. { name: 'findAllProvider', offset: 0, pagecount: 0, params: [] },
  333. { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
  334. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  335. { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  336. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  337. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] }
  338. ],
  339. requestParamDelete: {
  340. },
  341. requestFilterParams: {
  342. },
  343. temp: {
  344. },
  345. storage: {
  346. inputDatetime: parseTime(new Date(), '{y}-{m}-{d}'),
  347. typeName: '',
  348. assTypeId: '',
  349. employeId: this.$store.state.user.employeid,
  350. departmentId: this.$store.state.user.departmentid,
  351. pastureId: this.$store.state.user.pastureid,
  352. laidNumber: ''
  353. },
  354. dialogFormVisibleErro: false,
  355. dialogStatusErro: '',
  356. textMap: {
  357. erro: '导入错误信息'
  358. },
  359. dialogPvVisible: false,
  360. // 校验规则
  361. rules: {},
  362. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  363. cellStyle: { padding: 0 + 'px' },
  364. selection: []
  365. }
  366. },
  367. computed: {
  368. // 设置请求头
  369. headers() {
  370. return {
  371. // 设置token
  372. // eslint-disable-next-line no-undef
  373. token: getToken()
  374. }
  375. },
  376. uploadData() {
  377. return {
  378. name: 'importStockLaid',
  379. importParams: '牧场,入库单编号,入库日期,物料编码,品名,规格型号,品牌,计量单位,数量,单价,总价,库位,供应商,jwt_username',
  380. sheetname: 'SheetJS'
  381. }
  382. },
  383. // 设置上传地址
  384. uploadExcelUrl() {
  385. // process.env.VUE_APP_BASE_API是服务器的路径,也是axios的基本路径
  386. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  387. }
  388. },
  389. created() {
  390. this.get_select_list()
  391. this.get_table_dataImportInfo()
  392. },
  393. methods: {
  394. // 供应商模糊查询
  395. providerSearch(queryString, cb) {
  396. var returnList = this.findAllProvider
  397. var results = queryString ? returnList.filter(this.createFilter(queryString)) : returnList
  398. // 调用 callback 返回建议列表的数据
  399. cb(results)
  400. },
  401. createFilter(queryString) {
  402. console.log(queryString)
  403. return returnValue => {
  404. return (
  405. returnValue.name.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
  406. )
  407. }
  408. },
  409. handleSelect(item) {
  410. this.temp.providerId = item.id
  411. this.temp.providerName = item.name
  412. },
  413. // 模糊查询 --查询申购单信息
  414. purchaseSearch(queryString, cb) {
  415. this.requestFilterParams.name = 'findPurchaseSolr'
  416. this.requestFilterParams.parammaps = {}
  417. this.requestFilterParams.parammaps['orderA'] = queryString
  418. this.requestFilterParams.parammaps['pastureId'] = this.$store.state.user.pastureid
  419. GetDataByName(this.requestFilterParams).then(response => {
  420. // console.log(response.data.list)
  421. cb(response.data.list)
  422. })
  423. },
  424. // 导出模板
  425. handleDownloadTemp() {
  426. this.requestParam.name = 'stockLaidDownTemp'
  427. GetDataByName(this.requestParam).then(response => {
  428. this.$nextTick(() => {
  429. import('@/vendor/Export2Excel').then(excel => {
  430. const list1 = response.data.list
  431. const tHeader = [
  432. '牧场', '入库单编号', '入库日期', '物料编码', '品名', '规格型号', '品牌', '计量单位', '数量', '单价', '总价', '库位', '供应商']
  433. const filterVal = [
  434. '牧场', '入库单编号', '入库日期', '物料编码', '品名', '规格型号', '品牌', '计量单位', '数量', '单价', '总价', '库位', '供应商']
  435. const data1 = this.formatJsonTemp(filterVal, list1)
  436. excel.export_json_to_excel({
  437. header: tHeader,
  438. data: data1,
  439. filename: '入库模板',
  440. autoWidth: true,
  441. bookType: 'xlsx'
  442. })
  443. })
  444. })
  445. })
  446. },
  447. formatJsonTemp(filterVal, jsonData) {
  448. return jsonData.map(v =>
  449. filterVal.map(j => {
  450. if (j === 'timestamp') {
  451. return parseTime(v[j])
  452. } else {
  453. return v[j]
  454. }
  455. })
  456. )
  457. },
  458. // 导入
  459. beforeImportExcel(file) {
  460. /* const isExcel =
  461. file.type ===
  462. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' */
  463. const isLt2M = file.size / 1024 / 1024 < 10
  464. /* if (!isExcel) {
  465. this.$message.error(
  466. '上传文件必须是Xlsx格式!建议先导出,再修改导出文件再导入!'
  467. )
  468. }*/
  469. if (!isLt2M) {
  470. this.$message.error('上传文件大小不能超过 10MB!')
  471. }
  472. return isLt2M
  473. },
  474. handleImportExcelSuccess(res, file) {
  475. if (res.msg === 'ok') {
  476. this.$message({
  477. title: '成功',
  478. message: '导入成功:' + res.data.success + '条!',
  479. type: 'success',
  480. duration: 2000
  481. })
  482. if (res.data.err_count > 0) {
  483. this.dialogFormVisibleErro = true
  484. this.dialogStatusErro = 'erro'
  485. this.listErro = res.data.result
  486. setTimeout(() => {
  487. this.listLoadingErro = false
  488. }, 100)
  489. this.$notify({
  490. title: '失败',
  491. message: '导入失败:' + res.data.err_count + '条!',
  492. type: 'danger',
  493. duration: 2000
  494. })
  495. }
  496. } else {
  497. this.$notify({
  498. title: '失败',
  499. message: '上传失败',
  500. type: 'danger',
  501. duration: 2000
  502. })
  503. }
  504. },
  505. // 1-1: 导入信息table&搜索
  506. get_table_dataImportInfo() {
  507. this.listLoadingImportInfo = true
  508. if (this.getdataListParmImportInfo.parammaps.storageTime === null) {
  509. this.getdataListParmImportInfo.parammaps.storageTime = ''
  510. }
  511. GetDataByName(this.getdataListParmImportInfo).then(response => {
  512. this.listImportInfo = response.data.list
  513. this.pageNum = response.data.pageNum
  514. this.pageSize = response.data.pageSize
  515. // console.log(this.list)
  516. if (response.data.total) {
  517. this.totalImportInfo = response.data.total
  518. }
  519. // Just to simulate the time of the request
  520. setTimeout(() => {
  521. this.listLoadingImportInfo = false
  522. }, 100)
  523. })
  524. },
  525. form_searchImportInfo() {
  526. this.listLoadingImportInfo = true
  527. this.get_table_dataImportInfo()
  528. },
  529. // 2-2:下拉框
  530. get_select_list() {
  531. GetDataByNames(this.requestParams).then(response => {
  532. this.findAllProvider = response.data.findAllProvider.list
  533. this.findAllAssetType = response.data.findAllAssetType.list
  534. this.findAllPasture = response.data.findAllPasture.list
  535. this.findAllDepart = response.data.findAllDepart.list
  536. this.findAllEmploye = response.data.findAllEmploye.list
  537. this.getDictByName = response.data.getDictByName.list
  538. })
  539. },
  540. form_search() {
  541. this.listLoading = true
  542. this.getdataListParmImportInfo.offset = 1
  543. this.get_table_dataImportInfo()
  544. // this.get_table_data()
  545. },
  546. handleModifyStatus(row, status) {
  547. this.$message({
  548. message: '操作成功',
  549. type: 'success'
  550. })
  551. row.status = status
  552. },
  553. form_reset() {
  554. this.list2 = []
  555. this.storage.inputDatetime = parseTime(new Date(), '{y}-{m}-{d}')
  556. this.storage.typeName = ''
  557. this.storage.assTypeId = ''
  558. this.storage.employeId = this.$store.state.user.employeid
  559. this.storage.departmentId = this.$store.state.user.departmentid
  560. this.storage.pastureId = this.$store.state.user.pastureid
  561. },
  562. // 选择要删除的数据
  563. handleSelectionChange(val) {
  564. // console.log(val)
  565. this.selection = val
  566. },
  567. // 删除
  568. form_delete(selection) {
  569. // console.log('selection', selection)
  570. this.parammapsId = []
  571. for (var i = 0; i < selection.length; i++) {
  572. console.log(selection[i])
  573. this.parammapsId.push(selection[i])
  574. }
  575. console.log(this.parammapsId)
  576. if (selection.length === 0) {
  577. this.$message({
  578. type: 'info',
  579. message: '请选中要删除的数据'
  580. })
  581. } else {
  582. MessageBox.confirm('确认删除?', {
  583. confirmButtonText: '确认',
  584. cancelButtonText: '取消',
  585. type: 'warning'
  586. }).then(() => {
  587. this.requestParamDelete.common = { 'returnmap': '0' }
  588. this.postDataPramas.data = []
  589. this.postDataPramas.data[0] = { 'name': 'deleteIStockLaidList', 'resultmaps': { 'list': this.parammapsId }}
  590. this.postDataPramas.data[0].children = []
  591. this.postDataPramas.data[0].children[0] = { 'name': 'deleteIStockLaid', 'type': 'e', 'parammaps': { }}
  592. this.postDataPramas.data[0].children[0].parammaps.id = '@deleteIStockLaidList.id'
  593. this.postDataPramas.data[0].children[0].parammaps.pastureId = '@deleteIStockLaidList.pastureId'
  594. this.postDataPramas.data[0].children[0].parammaps.stockNumber = '@deleteIStockLaidList.stockNumber'
  595. this.postDataPramas.data[0].children[0].parammaps.providerName = '@deleteIStockLaidList.providerName'
  596. this.postDataPramas.data[0].children[0].parammaps.location = '@deleteIStockLaidList.location'
  597. this.postDataPramas.data[0].children[0].parammaps.amount = '@deleteIStockLaidList.amount'
  598. ExecDataByConfig(this.postDataPramas).then(response => {
  599. if (response.msg === 'fail') {
  600. this.$notify({
  601. title: '删除失败',
  602. message: response.data,
  603. type: 'warning',
  604. duration: 2000
  605. })
  606. } else {
  607. this.get_table_dataImportInfo()
  608. this.dialogFormVisible = false
  609. this.$notify({
  610. title: '',
  611. message: '删除成功',
  612. type: 'success',
  613. duration: 2000
  614. })
  615. }
  616. })
  617. }).catch(() => {
  618. this.$message({
  619. type: 'info',
  620. message: '已取消删除'
  621. })
  622. })
  623. }
  624. }
  625. }
  626. }
  627. </script>