breakage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="app-container">
  3. <!-- 查询表单区域 -->
  4. <el-form :model="listQuery" size="small" :inline="true" label-position="top">
  5. <el-row :gutter="20">
  6. <el-col :span="6">
  7. <el-form-item label="开始日期">
  8. <el-date-picker v-model="listQuery.startDate" value-format="yyyy-MM-dd" type="date"
  9. placeholder="开始日期" style="width: 100%">
  10. </el-date-picker>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="6">
  14. <el-form-item label="结束日期">
  15. <el-date-picker v-model="listQuery.endDate" value-format="yyyy-MM-dd" type="date"
  16. placeholder="结束日期" style="width: 100%">
  17. </el-date-picker>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="6">
  21. <el-form-item label="仓库">
  22. <el-select v-model="listQuery.warehouseId" clearable filterable
  23. placeholder="仓库" style="width: 100%">
  24. <el-option :key="item.id" v-for="item in warehouseList"
  25. :label="item.warehouseName" :value="item.id">
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="经手人">
  32. <el-select v-model="listQuery.addHandlerId" clearable filterable
  33. placeholder="经手人" style="width: 100%">
  34. <el-option :key="item.loginId" v-for="item in userSelsctList"
  35. :label="item.deptName+'_'+item.userName" :value="item.loginId">
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row :gutter="20">
  42. <el-col :span="6">
  43. <el-form-item label="报损状态">
  44. <el-select v-model="listQuery.isRunFinish" clearable
  45. placeholder="请选择状态" style="width: 100%">
  46. <el-option :key="item.type" v-for="item in typeList"
  47. :label="item.name" :value="item.type">
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. <el-row :gutter="20">
  54. <el-col :span="6">
  55. <el-form-item label="搜索">
  56. <el-button style="width: 100%;" type="primary" icon="el-icon-search"
  57. @click="handleFilter">搜索</el-button>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <el-form-item label="重置">
  62. <el-button style="width: 100%;" icon="el-icon-refresh" type="primary"
  63. @click="resetQuery">重置</el-button>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. </el-form>
  68. <!-- 操作按钮区域 -->
  69. <el-row :gutter="10" class="mb8">
  70. <el-col :span="1.5">
  71. <el-button type="primary" class="editButton" size="small"
  72. icon="el-icon-plus" @click="handleCreate">添加</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button type="warning" icon="el-icon-download" size="small"
  76. @click="handleDownload">导出</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button type="danger" icon="el-icon-delete" size="small"
  80. @click="delAll">批量删除</el-button>
  81. </el-col>
  82. </el-row>
  83. <!-- 表格区域 -->
  84. <div class="border-card">
  85. <el-table height="450" size="small" :data="list" @selection-change="handleSelectionChange"
  86. v-loading="listLoading" element-loading-text="正在查询中。。。" border fit highlight-current-row>
  87. <el-table-column type="selection" width="55px" align="center"></el-table-column>
  88. <el-table-column type="index" label="序号" header-align="center" align="center"></el-table-column>
  89. <el-table-column align="center" min-width="150px" label="报损单号">
  90. <template slot-scope="scope">
  91. <router-link :to="{ name: 'breakageDetail', params: { id: scope.row.id } }">
  92. <div style="color: #337ab7;cursor: pointer;">{{ scope.row.serialCode }}</div>
  93. </router-link>
  94. </template>
  95. </el-table-column>
  96. <el-table-column align="center" min-width="100px" label="报损时间" prop="serialDate"></el-table-column>
  97. <el-table-column align="center" min-width="100px" label="仓库" prop="warehouseName"></el-table-column>
  98. <el-table-column align="center" min-width="100px" label="经手人" prop="addHandlerName"></el-table-column>
  99. <el-table-column align="center" min-width="100px" label="报损状态">
  100. <template slot-scope="props">
  101. <span v-if="props.row.isRunFinish == '0'" style="color: #67C23A;font-weight: bold;">已报损</span>
  102. <span v-if="props.row.isRunFinish == '1'" style="color: #E6A23C;font-weight: bold;">待报损</span>
  103. <span v-if="props.row.isRunFinish == '2'" style="color: #E6A23C;font-weight: bold;">已作废</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column align="center" min-width="200px" label="报损原因" prop="remarks"></el-table-column>
  107. <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
  108. <template slot-scope="scope">
  109. <el-button v-if="scope.row.isRunFinish == '1'" type="text" icon="el-icon-success"
  110. class="openText" size="small" @click="handleExecute(scope.row)">报损</el-button>
  111. <el-button v-if="scope.row.isRunFinish == '1'" type="text" icon="el-icon-edit"
  112. class="editText" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
  113. <el-button v-if="scope.row.isRunFinish != '0'" type="text" icon="el-icon-delete"
  114. class="deleteText" size="small" @click="handleDelete(scope.row)">删除</el-button>
  115. <el-button v-if="scope.row.isRunFinish == '0'" type="text" icon="el-icon-close"
  116. class="closeText" size="small" @click="handleCancelShow(scope.row.id)">作废</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <!-- 分页 -->
  121. <div class="pagination-container">
  122. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  123. :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
  124. layout="total, sizes, prev, pager, next, jumper" :total="total">
  125. </el-pagination>
  126. </div>
  127. </div>
  128. <!-- 作废原因对话框 -->
  129. <el-dialog :close-on-click-modal="false" title="单据作废" :visible.sync="dialogFormVisible" width="40%">
  130. <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="80px">
  131. <el-form-item label="作废原因" prop="cancelMsg">
  132. <el-input type="textarea" :rows="2" placeholder="请输入作废原因" v-model="dataForm.cancelMsg"></el-input>
  133. </el-form-item>
  134. </el-form>
  135. <div slot="footer" class="dialog-footer">
  136. <el-button @click="dialogFormVisible = false">取消</el-button>
  137. <el-button type="primary" @click="handleCancel()">确定</el-button>
  138. </div>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. import { listBreakage, deleteBreakage, executeBreakage, cancelBreakage } from "@/api/breakage";
  144. import { warehouseList } from "@/api/warehouse";
  145. import { allUserList } from "@/api/public";
  146. export default {
  147. data() {
  148. return {
  149. cancelId: '',
  150. dialogFormVisible: false,
  151. dataForm: {
  152. cancelMsg: ''
  153. },
  154. rules: {
  155. cancelMsg: [{ required: true, message: "作废原因不能为空", trigger: "blur" }],
  156. },
  157. typeList: [
  158. { type: '0', name: "已报损" },
  159. { type: '1', name: "待报损" },
  160. { type: '2', name: "已作废" },
  161. ],
  162. warehouseList: [],
  163. userSelsctList: [],
  164. list: [],
  165. delarr: [],
  166. multipleSelection: [],
  167. total: 0,
  168. listLoading: false,
  169. listQuery: {
  170. page: 1,
  171. limit: 10,
  172. startDate: '',
  173. endDate: '',
  174. warehouseId: '',
  175. addHandlerId: '',
  176. isRunFinish: '',
  177. },
  178. }
  179. },
  180. created() {
  181. this.getStoreList();
  182. this.getAllUserList();
  183. this.getList();
  184. },
  185. methods: {
  186. handleCancelShow(id) {
  187. this.dialogFormVisible = true;
  188. this.cancelId = id;
  189. this.$nextTick(() => {
  190. this.dataForm.cancelMsg = '';
  191. this.$refs["dataForm"].clearValidate();
  192. });
  193. },
  194. handleCancel() {
  195. this.$refs["dataForm"].validate((valid) => {
  196. if (valid) {
  197. cancelBreakage({ id: this.cancelId, cancelMsg: this.dataForm.cancelMsg }).then(() => {
  198. this.dialogFormVisible = false;
  199. this.$notify({
  200. title: "成功",
  201. message: "操作成功",
  202. type: "success",
  203. duration: 2000,
  204. });
  205. this.getList();
  206. });
  207. }
  208. })
  209. },
  210. getStoreList() {
  211. warehouseList().then(response => {
  212. this.warehouseList = response.data.data;
  213. }).catch(() => { });
  214. },
  215. getAllUserList() {
  216. allUserList().then(response => {
  217. this.userSelsctList = response.data.data;
  218. }).catch(() => { });
  219. },
  220. resetQuery() {
  221. this.listQuery = {
  222. page: 1,
  223. limit: 10,
  224. startDate: '',
  225. endDate: '',
  226. warehouseId: '',
  227. addHandlerId: '',
  228. isRunFinish: '',
  229. };
  230. this.getList();
  231. },
  232. handleDownload() {
  233. window.location.href = process.env.BASE_API + '/warehouse-breakage/export';
  234. },
  235. handleCreate() {
  236. this.$router.push({ name: 'breakageAdd' });
  237. },
  238. getList() {
  239. this.listLoading = true;
  240. listBreakage(this.listQuery).then(response => {
  241. this.list = response.data.data.items;
  242. this.total = response.data.data.total;
  243. this.listLoading = false;
  244. }).catch(() => {
  245. this.list = [];
  246. this.total = 0;
  247. this.listLoading = false;
  248. });
  249. },
  250. handleFilter() {
  251. this.listQuery.page = 1;
  252. this.getList();
  253. },
  254. handleSizeChange(val) {
  255. this.listQuery.limit = val;
  256. this.getList();
  257. },
  258. handleCurrentChange(val) {
  259. this.listQuery.page = val;
  260. this.getList();
  261. },
  262. handleUpdate(row) {
  263. this.$router.push({ name: 'breakageEdit', params: { id: row.id } });
  264. },
  265. handleExecute(row) {
  266. this.$confirm('确认报损吗?', '提示', {
  267. confirmButtonText: '确定',
  268. cancelButtonText: '取消',
  269. type: 'warning'
  270. }).then(() => {
  271. executeBreakage({ ids: row.id }).then(response => {
  272. this.$notify({
  273. title: '成功',
  274. message: '报损成功',
  275. type: 'success',
  276. duration: 2000
  277. });
  278. this.getList();
  279. });
  280. }).catch(() => { });
  281. },
  282. executeAll() {
  283. const length = this.multipleSelection.length;
  284. if (length > 0) {
  285. this.$confirm("确认报损吗?", "提示", {
  286. confirmButtonText: "确定",
  287. cancelButtonText: "取消",
  288. type: "warning",
  289. }).then(() => {
  290. for (let i = 0; i < length; i++) {
  291. this.delarr.push(this.multipleSelection[i].id);
  292. }
  293. const ids = this.delarr.join(",");
  294. executeBreakage({ ids: ids }).then(() => {
  295. this.$notify({
  296. title: "成功",
  297. message: "报损成功",
  298. type: "success",
  299. duration: 2000,
  300. });
  301. this.getList();
  302. });
  303. });
  304. } else {
  305. this.$notify({
  306. title: "提示",
  307. message: "请选择要报损的信息!",
  308. type: "warning",
  309. });
  310. }
  311. },
  312. handleDelete(row) {
  313. this.$confirm('确认删除吗?', '提示', {
  314. confirmButtonText: '确定',
  315. cancelButtonText: '取消',
  316. type: 'warning'
  317. }).then(() => {
  318. deleteBreakage({ ids: row.id }).then(response => {
  319. this.$notify({
  320. title: '成功',
  321. message: '删除成功',
  322. type: 'success',
  323. duration: 2000
  324. });
  325. this.getList();
  326. });
  327. }).catch(() => { });
  328. },
  329. delAll() {
  330. const length = this.multipleSelection.length;
  331. if (length > 0) {
  332. this.$confirm("确认删除吗?", "提示", {
  333. confirmButtonText: "确定",
  334. cancelButtonText: "取消",
  335. type: "warning",
  336. }).then(() => {
  337. for (let i = 0; i < length; i++) {
  338. this.delarr.push(this.multipleSelection[i].id);
  339. }
  340. const ids = this.delarr.join(",");
  341. deleteBreakage({ ids: ids }).then(() => {
  342. this.$notify({
  343. title: "成功",
  344. message: "删除成功",
  345. type: "success",
  346. duration: 2000,
  347. });
  348. this.getList();
  349. });
  350. });
  351. } else {
  352. this.$notify({
  353. title: "提示",
  354. message: "请选择要删除的信息!",
  355. type: "warning",
  356. });
  357. }
  358. },
  359. handleSelectionChange(val) {
  360. this.multipleSelection = val;
  361. },
  362. }
  363. }
  364. </script>