goodsInventoryLoss.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div>
  3. <div class="search">
  4. <el-form ref="advancedForm" :model="advancedForm" label-width="160px">
  5. <el-row>
  6. <el-col :span="8">
  7. <el-form-item label="报损日期">
  8. <el-date-picker v-model="advancedForm.goodsInventory_time_range" type="daterange" align="center"
  9. :editable="false" unlink-panels :clearable="false" :default-time="['00:00:00', '23:59:59']"
  10. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" value-format="timestamp"
  11. :picker-options="{ disabledDate(time) { return time.getTime() - 1 >= new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()).getTime() + 86400000 - 1 }, shortcuts: MixinPickerShortcuts }">
  12. </el-date-picker>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="8">
  16. <el-form-item label="仓库">
  17. <el-select v-model="advancedForm.warehouse_id">
  18. <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
  19. </el-select>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="报损人">
  24. <el-input v-model="advancedForm.creator" placeholder="请输入内容" width="200px"></el-input>
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. </el-form>
  29. <el-button @click="advancedSearchEvent">
  30. 搜索
  31. </el-button>
  32. </div>
  33. <en-table-layout :tableData="tableData.data" :loading="loading" @selection-change="handleSelectionChange">
  34. <div slot="toolbar" class="inner-toolbar">
  35. <div class="toolbar-btns">
  36. <el-button size="mini" v-if="checkPermission(['goodsInventoryLoss:add'])" type="primary"
  37. @click="handleAddGoodsInventoryLoss">新增</el-button>
  38. <!-- <el-button v-if="checkPermission(['goodsInventoryLoss:del'])" size="mini" @click="handleDeleteGoodsInventoryLoss()"
  39. type="danger" :disabled="multipleSelection.length === 0">删除</el-button> -->
  40. </div>
  41. </div>
  42. <template slot="table-columns">
  43. <el-table-column type="selection" width="55" />
  44. <el-table-column prop="sn" label="报损单编号">
  45. <template slot-scope="scope">
  46. <!-- <router-link
  47. v-if="checkPermission(['goodsInventoryLoss'])"
  48. style="color: #409eff;"
  49. :to="{ name: 'goodsInventoryLossDetail', params: { id: scope.row.id } }">
  50. {{ scope.row.sn }}
  51. </router-link> -->
  52. <span>{{ scope.row.sn }}</span>
  53. </template>
  54. </el-table-column>
  55. <!-- <el-table-column prop="report_time" label="报损日期">
  56. <template slot-scope="scope">{{ scope.row.report_time }}</template>
  57. </el-table-column> -->
  58. <el-table-column label="仓库">
  59. <template slot-scope="scope">{{ warehouseName(scope.row.warehouse_id) }}</template>
  60. </el-table-column>
  61. <!--<el-table-column prop="creator" label="报损人" />
  62. <el-table-column prop="damage_type_key" label="审核人" /> -->
  63. <el-table-column prop="status" label="状态">
  64. <template slot-scope="scope">{{ statusFilter(scope.row.status) }}</template>
  65. </el-table-column>
  66. <!-- <el-table-column prop="dept_name" label="报损数量" /> -->
  67. <el-table-column prop="report_desc" label="报损说明" />
  68. <el-table-column label="操作" width="450">
  69. <template slot-scope="scope">
  70. <el-button type="mini" size="mini" @click="handleDetailGoodsInventoryLoss(scope.row)">查看</el-button>
  71. <el-button type="mini" size="mini" v-if="scope.row.status == 'NOT_HANDLE' && checkPermission(['goodsInventoryLoss:submit'])"
  72. @click="handleSubmitGoodsInventoryLoss(scope.row)">审核</el-button>
  73. <!--<el-button v-if="scope.row.allowable.allow_audit && checkPermission(['goodsInventoryLoss:audit'])" type="mini"
  74. size="mini" @click="handleAuditGoodsInventoryLoss(scope.row)">审核</el-button>
  75. <el-button v-if="scope.row.allowable.allow_cancel && checkPermission(['goodsInventoryLoss:cancel'])" type="mini"
  76. size="mini" @click="handleCancelGoodsInventoryLoss(scope.row)">撤回</el-button>
  77. <el-button v-if="scope.row.allowable.allow_edit && checkPermission(['goodsInventoryLoss:edit'])" size="mini"
  78. @click="handleEditGoodsInventoryLoss(scope.row)">编辑</el-button> -->
  79. </template>
  80. </el-table-column>
  81. </template>
  82. <el-pagination v-if="tableData" slot="pagination" @size-inventory="handlePageSizeChange"
  83. @current-inventory="handlePageCurrentChange" :current-page="tableData.page_no" :page-sizes="[10, 20, 50, 100]"
  84. :page-size="tableData.page_size" layout="total, sizes, prev, pager, next, jumper" :total="tableData.data_total">
  85. </el-pagination>
  86. </en-table-layout>
  87. </div>
  88. </template>
  89. <script>
  90. import * as API_GoodsInventoryLoss from '@/api/goodsInventoryLoss'
  91. import Print from 'print-js'
  92. import * as API_Setting from '@/api/setting'
  93. import * as API_BasicSetting from '@/api/basicSetting'
  94. import { Foundation } from '~/ui-utils'
  95. export default {
  96. name: 'GoodsInventoryLoss',
  97. data() {
  98. return {
  99. warehouseList: [],
  100. deptList: [],
  101. // 列表loading状态
  102. loading: false,
  103. // 列表参数
  104. params: {
  105. page_no: 1,
  106. page_size: 10
  107. },
  108. // 高级搜索数据
  109. advancedForm: {},
  110. // 列表数据
  111. tableData: '',
  112. // 当前已选择的行
  113. multipleSelection: [],
  114. GoodsInventoryLossForm: {}
  115. }
  116. },
  117. mounted() {
  118. this.GET_GoodsInventoryLossList()
  119. this.GET_DeptList()
  120. this.GET_WarehouseList()
  121. },
  122. watch: {
  123. $route: function ({ query }) {
  124. this.params.page_no = 1
  125. this.GET_GoodsInventoryLossList()
  126. }
  127. },
  128. methods: {
  129. // 查看
  130. handleDetailGoodsInventoryLoss(row) {
  131. this.$router.push({
  132. name: 'goodsInventoryLossDetail',
  133. params: { id: row.id }
  134. })
  135. },
  136. //获取仓库名称
  137. warehouseName(val) {
  138. let name = ''
  139. this.warehouseList.map(el => {
  140. if (el.id == val) {
  141. return name = el.name
  142. }
  143. })
  144. return name
  145. },
  146. /** 获取仓库 */
  147. GET_WarehouseList() {
  148. API_BasicSetting.getWarehouseListAll().then(response => {
  149. this.warehouseList = response
  150. })
  151. },
  152. handleAuditGoodsInventoryLoss(row) {
  153. this.$router.push({
  154. name: 'goodsInventoryLossAudit',
  155. params: {
  156. id: row.id
  157. }
  158. })
  159. },
  160. handleEditGoodsInventoryLoss(row) {
  161. this.$router.push({
  162. name: 'goodsInventoryLossEdit',
  163. params: { id: row.id }
  164. })
  165. },
  166. /** 处理 */
  167. handleSubmitGoodsInventoryLoss(row) {
  168. /* API_GoodsInventoryLoss.getSyncStock(row.id).then(() => {
  169. this.$message.success('处理成功!')
  170. this.GET_GoodsInventoryLossList()
  171. }) */
  172. this.$router.push({
  173. name: 'goodsInventoryLossEdit',
  174. params: { id: row.id }
  175. })
  176. },
  177. /** 撤回 */
  178. handleCancelGoodsInventoryLoss(row) {
  179. API_GoodsInventoryLoss.cancelGoodsInventoryLoss(row.id).then(() => {
  180. this.$message.success('撤回成功!')
  181. this.GET_GoodsInventoryLossList()
  182. })
  183. },
  184. /** 确认 */
  185. handleConfirmGoodsInventoryLoss(row) {
  186. // if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.error('请先选择!')
  187. this.$confirm('确定吗?', '提示', { type: 'warning' }).then(() => {
  188. // const ids = this.multipleSelection.map(item => item.id)
  189. API_GoodsInventoryLoss.InventoryLossFormConfirm(row.id).then(() => {
  190. this.$message.success('确认成功!')
  191. this.GET_GoodsInventoryLossList()
  192. })
  193. }).catch(() => { })
  194. },
  195. /** 添加调整单 */
  196. handleAddGoodsInventoryLoss() {
  197. this.$router.push({
  198. name: 'goodsInventoryLossAdd',
  199. params: { callback: this.GET_GoodsInventoryLossList }
  200. })
  201. },
  202. /** 打印调整单 */
  203. handlePrintGoodsInventoryLossDialog(row) {
  204. this.GET_GoodsInventoryLossDetail(row.id)
  205. },
  206. /** 删除 */
  207. handleDeleteGoodsInventoryLoss() {
  208. console.log('this.multipleSelection=', this.multipleSelection)
  209. if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.error('请先选择!')
  210. this.$confirm('确定要删除当前调整单吗?', '提示', { type: 'warning' }).then(() => {
  211. const ids = this.multipleSelection.map(item => item.id)
  212. API_GoodsInventoryLoss.deleteGoodsInventoryLoss(ids).then(() => {
  213. this.$message.success('删除成功!')
  214. this.GET_GoodsInventoryLossList()
  215. })
  216. }).catch(() => { })
  217. },
  218. /** 状态 */
  219. statusFilter(val) {
  220. switch (val) {
  221. case 'NOT_HANDLE':
  222. return '未处理'
  223. case 'HAS_HANDLE':
  224. return '已处理'
  225. }
  226. },
  227. /** 获取部门 */
  228. GET_DeptList() {
  229. API_Setting.getDeptList().then(response => {
  230. this.deptList = Foundation.buildTree(response, '0')
  231. })
  232. },
  233. /** 打印对账详情 */
  234. handlePrintGoodsInventoryLoss() {
  235. Print({
  236. printable: 'deliverySheet',
  237. type: 'html',
  238. targetStyles: ['*'],
  239. ignoreElements: ['no-logs', 'goods-image', 'no-btn']
  240. })
  241. },
  242. /** 多选改变 */
  243. handleSelectionChange(val) {
  244. console.log('val=-', val)
  245. this.multipleSelection = val
  246. },
  247. /** 分页大小发生改变 */
  248. handlePageSizeChange(size) {
  249. this.params.page_size = size
  250. this.GET_GoodsInventoryLossList()
  251. },
  252. /** 分页页数发生改变 */
  253. handlePageCurrentChange(page) {
  254. this.params.page_no = page
  255. this.GET_GoodsInventoryLossList()
  256. },
  257. /** 搜索事件触发 */
  258. searchEvent(data) {
  259. this.params = {
  260. ...this.params,
  261. sn: data
  262. }
  263. Object.keys(this.advancedForm).forEach((key) => delete this.params[key])
  264. this.params.page_no = 1
  265. this.GET_GoodsInventoryLossList()
  266. },
  267. /** 高级搜索事件触发 */
  268. advancedSearchEvent() {
  269. this.params = {
  270. ...this.params,
  271. ...this.advancedForm
  272. }
  273. delete this.params.start_time
  274. delete this.params.end_time
  275. if (this.advancedForm.GoodsInventoryLoss_time_range) {
  276. this.params.start_time = parseInt(Number(this.advancedForm.GoodsInventoryLoss_time_range[0]) / 1000)
  277. this.params.end_time = parseInt(Number(this.advancedForm.GoodsInventoryLoss_time_range[1]) / 1000)
  278. }
  279. delete this.params.GoodsInventoryLoss_time_range
  280. this.params.page_no = 1
  281. this.GET_GoodsInventoryLossList()
  282. },
  283. /** 获取调整单列表 */
  284. GET_GoodsInventoryLossList() {
  285. this.loading = true
  286. API_GoodsInventoryLoss.getGoodsInventoryLossList(this.params).then(response => {
  287. this.loading = false
  288. this.tableData = response
  289. }).catch(() => { this.loading = false })
  290. }
  291. }
  292. }
  293. </script>
  294. <style type="text/scss" lang="scss" scoped>
  295. .search {
  296. display: flex;
  297. align-items: center;
  298. background: #fff;
  299. overflow: hidden;
  300. padding: 30px 10px 10px 10px;
  301. /deep/ .el-form-item {
  302. .el-form-item__content {
  303. .el-input {
  304. width: 200px;
  305. }
  306. }
  307. }
  308. .el-button {
  309. margin-top: -19px;
  310. margin-left: 20px;
  311. }
  312. }
  313. .print {
  314. margin-left: 790px;
  315. }
  316. .deliverySheet-header {
  317. display: flex;
  318. justify-content: center;
  319. align-items: center;
  320. }
  321. .tips-t {
  322. display: flex;
  323. padding: 30px 0;
  324. div {
  325. flex: 1;
  326. text-align: left;
  327. padding-left: 70px;
  328. }
  329. }
  330. .tips-f {
  331. padding: 20px 0;
  332. }
  333. .face-image {
  334. display: block;
  335. width: 50px;
  336. height: 50px;
  337. margin: 0 auto;
  338. }
  339. /deep/ .el-dialog__body {
  340. padding: 10px 20px;
  341. }
  342. </style>