index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <!-- <el-form-item label="任务编码" prop="taskCode">-->
  5. <!-- <el-input-->
  6. <!-- v-model="queryParams.taskCode"-->
  7. <!-- placeholder="请输入任务编码"-->
  8. <!-- clearable-->
  9. <!-- @keyup.enter.native="handleQuery"-->
  10. <!-- />-->
  11. <!-- </el-form-item>-->
  12. <el-form-item label="领料编号" prop="requisitionNumber">
  13. <el-input
  14. v-model="queryParams.requisitionNumber"
  15. placeholder="请输入领料单编号"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="订单编号" prop="saleOrderNo">
  21. <el-input
  22. v-model="queryParams.saleOrderNo"
  23. placeholder="请输入订单编号"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="领料日期" prop="requisitionDate">
  29. <el-date-picker clearable
  30. v-model="queryParams.requisitionDate"
  31. type="date"
  32. value-format="yyyy-MM-dd"
  33. placeholder="请选择领料日期">
  34. </el-date-picker>
  35. </el-form-item>
  36. <el-form-item label="单据类型" prop="state">
  37. <el-select v-model="queryParams.requistionOrdersType" filterable placeholder="请选择任务领料"
  38. @change="handleQuery">
  39. <el-option key="1" label="领料" :value="0"/>
  40. <el-option key="2" label="退料" :value="1"/>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  45. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  46. </el-form-item>
  47. </el-form>
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['business:requisitionOrders:add']"
  57. >新增
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="success"
  63. plain
  64. icon="el-icon-edit"
  65. size="mini"
  66. :disabled="single"
  67. @click="handleUpdate"
  68. v-hasPermi="['business:requisitionOrders:edit']"
  69. >修改
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="danger"
  75. plain
  76. icon="el-icon-delete"
  77. size="mini"
  78. :disabled="multiple"
  79. @click="handleDelete"
  80. v-hasPermi="['business:requisitionOrders:remove']"
  81. >删除
  82. </el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="warning"
  87. plain
  88. icon="el-icon-download"
  89. size="mini"
  90. @click="handleExport"
  91. v-hasPermi="['business:requisitionOrders:export']"
  92. >导出
  93. </el-button>
  94. </el-col>
  95. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  96. </el-row>
  97. <el-table v-loading="loading" :data="requisitionOrdersList" @selection-change="handleSelectionChange">
  98. <el-table-column type="selection" width="55" align="center"/>
  99. <!-- <el-table-column label="领料单ID" align="center" prop="id"/>-->
  100. <!-- <el-table-column label="任务编码" align="center" prop="taskCode"/>-->
  101. <el-table-column label="领料单编号" align="center" prop="requisitionNumber"/>
  102. <el-table-column label="订单编号" align="center" prop="saleOrderNo"/>
  103. <el-table-column label="单据类型" align="center" prop="requistionOrdersType">
  104. <template slot-scope="scope">
  105. <el-tag v-if="scope.row.requistionOrdersType == 0">领料</el-tag>
  106. <el-tag v-else type="success">退料</el-tag>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="领料日期" align="center" prop="requisitionDate" width="180">
  110. <template slot-scope="scope">
  111. <span>{{ parseTime(scope.row.requisitionDate, '{y}-{m}-{d}') }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="状态" align="center" prop="state">
  115. <template slot-scope="scope">
  116. <dict-tag
  117. :options="dict.type.requisition_orders_state"
  118. :value="scope.row.state"
  119. />
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="备注" align="center" prop="remark"/>
  123. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  124. <template slot-scope="scope">
  125. <el-dropdown>
  126. <el-button type="warning" plain size="small">
  127. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  128. </el-button>
  129. <el-dropdown-menu slot="dropdown">
  130. <el-dropdown-item>
  131. <el-button v-show="scope.row.state == 0 || scope.row.state==3" size="mini" type="text"
  132. icon="el-icon-edit"
  133. @click="submitForApproval(scope.row)" v-hasPermi="['business:requisitionOrders:edit']">提交
  134. </el-button>
  135. </el-dropdown-item>
  136. <el-dropdown-item>
  137. <el-button v-show="scope.row.state == 2 && scope.row.requistionOrdersType == 0" size="mini" type="text"
  138. icon="el-icon-edit" @click="requistion(scope.row)"
  139. v-hasPermi="['business:requisitionOrders:edit']">领料
  140. </el-button>
  141. </el-dropdown-item>
  142. <el-dropdown-item>
  143. <el-button v-show="scope.row.state == 0 || scope.row.state== 3" size="mini" type="text"
  144. icon="el-icon-edit"
  145. @click="handleUpdate(scope.row)" v-hasPermi="['business:requisitionOrders:edit']">修改
  146. </el-button>
  147. </el-dropdown-item>
  148. <el-dropdown-item>
  149. <el-button v-show="scope.row.state == 0 || scope.row.state == 3" size="mini" type="text"
  150. icon="el-icon-delete"
  151. @click="handleDelete(scope.row)" v-hasPermi="['business:requisitionOrders:remove']">删除
  152. </el-button>
  153. </el-dropdown-item>
  154. <el-dropdown-item>
  155. <el-button
  156. v-show="scope.row.state == 5|| (scope.row.state ==2 && scope.row.requistionOrdersType == 1)"
  157. size="mini" type="text" icon="el-icon-delete" @click="handlePrint(scope.row)">打印单据
  158. </el-button>
  159. </el-dropdown-item>
  160. </el-dropdown-menu>
  161. </el-dropdown>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  166. @pagination="getList"/>
  167. <!-- 添加或修改领料单对话框 -->
  168. <el-dialog :title="requistionOrdersType?'退料单':'领料单'" :visible.sync="open" width="800px" append-to-body :before-close="cancel">
  169. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  170. <el-row :gutter="20">
  171. <el-col :span="8">
  172. <el-form-item label="单据类型" prop="requistionOrdersType">
  173. <el-select v-model="form.requistionOrdersType" filterable placeholder="请选择任务"
  174. :disabled="requistionState" @change="handleRequistionState(form.requistionOrdersType)">
  175. <el-option key="0" label="领料" :value=0></el-option>
  176. <el-option key="1" label="退料" :value=1></el-option>
  177. </el-select>
  178. </el-form-item>
  179. </el-col>
  180. <el-col :span="8">
  181. <el-form-item :label="requistionOrdersType?'退料任务':'领料任务'" prop="taskCode">
  182. <el-select v-model="form.taskCode" filterable placeholder="请选择任务" :disabled="requistionState"
  183. @change="handleRequistionState(form.requistionOrdersType)">
  184. <el-option v-for="item in taskList" :key="item.saleProductsId" :label="item.saleProductsTaskName"
  185. :value="item.saleProductsId"></el-option>
  186. </el-select>
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="8">
  190. <el-form-item :label="requistionOrdersType?'退料日期':'领料日期'" prop="requisitionDate">
  191. <el-date-picker style="width: 100%" v-model="form.requisitionDate" type="date"
  192. value-format="yyyy-MM-dd" placeholder="请选择领料日期"
  193. :disabled="requistionState"></el-date-picker>
  194. </el-form-item>
  195. </el-col>
  196. </el-row>
  197. <el-form-item label="备注" prop="remark">
  198. <el-input type="textarea" v-model="form.remark" placeholder="领料备注" :disabled="requistionState"/>
  199. </el-form-item>
  200. <el-divider content-position="center">物料信息</el-divider>
  201. <el-row :gutter="10" class="mb8" v-show="!requistionState && !requistionOrdersType">
  202. <el-col :span="1.5">
  203. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddRequisitionItems">添加
  204. </el-button>
  205. </el-col>
  206. <el-col :span="1.5">
  207. <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteRequisitionItems">删除
  208. </el-button>
  209. </el-col>
  210. </el-row>
  211. <el-table :style="requistionState?'float: left; width: 80%':requistionOrdersType?'float: left; width: 80%':''"
  212. :data="requisitionItemsList" :row-class-name="rowRequisitionItemsIndex"
  213. @selection-change="handleRequisitionItemsSelectionChange" ref="requisitionItems">
  214. <el-table-column type="selection" width="50" align="center" v-if="!requistionState"/>
  215. <el-table-column label="序号" align="center" prop="index" width="50"/>
  216. <el-table-column label="物料" prop="materialId" align="center">
  217. <template slot-scope="scope">
  218. <el-select v-model="scope.row.materialId" filterable placeholder="请选择物料"
  219. :disabled="requistionState?true:requistionOrdersType?true:false"
  220. @change="handleMaterielInfo(scope)">
  221. <el-option v-for="mtem in materielList" :key="mtem.id" :label="mtem.materielCode+''+mtem.materielName"
  222. :value="mtem.materielCode"></el-option>
  223. </el-select>
  224. </template>
  225. </el-table-column>
  226. <el-table-column :label="requistionOrdersType?'预计可退数量/重量':'预计领用数量/重量'" prop="quantity"
  227. align="center">
  228. <template slot-scope="scope">
  229. <el-input v-model="scope.row.quantity" type="number" placeholder="请输入预计领用数量/重量"
  230. :disabled="requistionState?true:requistionOrdersType?true:false"/>
  231. </template>
  232. </el-table-column>
  233. <el-table-column label="备注" prop="remark" width="250" align="center">
  234. <template slot-scope="scope">
  235. <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="requistionState?true:requistionOrdersType?true:false"/>
  236. </template>
  237. </el-table-column>
  238. </el-table>
  239. <div :style="requistionState?'':requistionOrdersType?'':'clear: both'"/>
  240. <el-table style="float: left;width: 20%" v-show="requistionState || requistionOrdersType"
  241. :data="requisitionItemsList" :row-class-name="rowRequisitionItemsIndex"
  242. @selection-change="handleRequisitionItemsSelectionChange" ref="requisitionItems">
  243. <el-table-column :label="requistionOrdersType?'回退数量/重量':'实际领用数量/重量'" prop="actualQuantity"
  244. width="150">
  245. <template slot-scope="scope">
  246. <el-input v-model="scope.row.actualQuantity" type="number"
  247. :placeholder="requistionOrdersType?'请输入回退数量/重量':'请输入实际领用数量/重量'"/>
  248. </template>
  249. </el-table-column>
  250. </el-table>
  251. <div style="clear: both"/>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button type="primary" @click="submitForm">确 定</el-button>
  255. <el-button @click="cancel">取 消</el-button>
  256. </div>
  257. </el-dialog>
  258. <div id="wuliao"></div>
  259. </div>
  260. </template>
  261. <script>
  262. import {
  263. listRequisitionOrders,
  264. getRequisitionOrders,
  265. delRequisitionOrders,
  266. addRequisitionOrders,
  267. updateRequisitionOrders, materialRequisitionTaskList, approvalOrders, getRequisitionOrdersByTaskCode
  268. } from "@/api/huaxian/requisitionOrders";
  269. import {queryMaterielList} from "@/api/tablelist/commonTable";
  270. export default {
  271. name: "RequisitionOrders",
  272. dicts: ["approval_process_status", "requisition_orders_state"],
  273. data() {
  274. return {
  275. // 遮罩层
  276. loading: true,
  277. // 选中数组
  278. ids: [],
  279. // 子表选中数据
  280. checkedRequisitionItems: [],
  281. // 非单个禁用
  282. single: true,
  283. // 非多个禁用
  284. multiple: true,
  285. // 显示搜索条件
  286. showSearch: true,
  287. // 总条数
  288. total: 0,
  289. // 领料单表格数据
  290. requisitionOrdersList: [],
  291. // 领料明细表格数据
  292. requisitionItemsList: [],
  293. // 弹出层标题
  294. title: "",
  295. // 是否显示弹出层
  296. open: false,
  297. // 查询参数
  298. queryParams: {
  299. pageNum: 1,
  300. pageSize: 10,
  301. taskCode: null,
  302. requistionOrdersType: 0,
  303. requisitionNumber: null,
  304. saleOrderNo: null,
  305. requisitionDate: null,
  306. state: null,
  307. createById: null,
  308. updateById: null,
  309. dataApprovalStatus: null,
  310. processKey: null,
  311. taskProcessKey: null,
  312. taskNodeKey: null
  313. },
  314. // 表单参数
  315. form: {},
  316. // 表单校验
  317. rules: {
  318. taskCode: [
  319. {required: true, message: '请选择任务领料', trigger: 'blur'}
  320. ],
  321. requisitionItemsList: {
  322. materialId: [
  323. {required: true, message: '请选择任务领料', trigger: 'blur'}
  324. ],
  325. }
  326. },
  327. // 可领料任务列表
  328. taskList: [],
  329. // 物料信息表
  330. materielList: [],
  331. // 领料状态 填写实际领料数量
  332. requistionState: false,
  333. // 单据类型 false:新增领料 true:退料
  334. requistionOrdersType: false,
  335. };
  336. },
  337. created() {
  338. this.getList();
  339. },
  340. methods: {
  341. /** 查询领料单列表 */
  342. getList() {
  343. this.loading = true;
  344. listRequisitionOrders(this.queryParams).then(response => {
  345. this.requisitionOrdersList = response.rows;
  346. this.total = response.total;
  347. this.loading = false;
  348. });
  349. },
  350. /** 查询可领料任务 */
  351. getTaskList() {
  352. materialRequisitionTaskList().then(response => {
  353. this.taskList = response.rows;
  354. });
  355. },
  356. /** 查询物料信息 */
  357. getMaterielList() {
  358. queryMaterielList().then(res => {
  359. this.materielList = res.data;
  360. });
  361. },
  362. // /** 查询字典(初始化所需数据)*/
  363. // initDictData() {
  364. // getDicts("approval_process_status").then((res) => {
  365. // //制定周期跑一次定时任务
  366. // console.log("字典中数据", res.data);
  367. // });
  368. // },
  369. // 处理领用物料信息
  370. handleMaterielInfo(scope) {
  371. scope.row.specifications = this.materielList.find(item => item.materielCode == scope.row.materialId).specificationModel
  372. },
  373. // 取消按钮
  374. cancel() {
  375. console.log("取消按钮")
  376. this.open = false;
  377. this.reset();
  378. // 领料状态
  379. this.requistionState = false;
  380. // 单据类型
  381. this.requistionOrdersType = false;
  382. },
  383. // 表单重置
  384. reset() {
  385. this.form = {
  386. id: null,
  387. taskCode: null,
  388. requisitionNumber: null,
  389. saleOrderNo: null,
  390. requisitionDate: null,
  391. requistionOrdersType: null,
  392. state: null,
  393. remark: null,
  394. createById: null,
  395. createBy: null,
  396. createTime: null,
  397. updateById: null,
  398. updateBy: null,
  399. updateTime: null,
  400. delFlag: null,
  401. dataApprovalStatus: null,
  402. processKey: null,
  403. taskProcessKey: null,
  404. taskNodeKey: null
  405. };
  406. this.requisitionItemsList = [];
  407. this.resetForm("form");
  408. },
  409. /** 搜索按钮操作 */
  410. handleQuery() {
  411. this.queryParams.pageNum = 1;
  412. this.getList();
  413. },
  414. /** 重置按钮操作 */
  415. resetQuery() {
  416. this.resetForm("queryForm");
  417. this.handleQuery();
  418. },
  419. // 多选框选中数据
  420. handleSelectionChange(selection) {
  421. this.ids = selection.map(item => item.id)
  422. this.single = selection.length !== 1
  423. this.multiple = !selection.length
  424. },
  425. /** 新增按钮操作 */
  426. handleAdd() {
  427. // 获取领料任务
  428. this.getTaskList();
  429. // 获取物料信息
  430. this.getMaterielList();
  431. this.reset();
  432. this.open = true;
  433. this.title = "添加领料单";
  434. // 默认领料时间为当前
  435. this.form.requisitionDate = new Date(new Date().toDateString());
  436. this.form.requistionOrdersType = 0;
  437. },
  438. /** 修改按钮操作 */
  439. handleUpdate(row) {
  440. //console.log(row)
  441. this.reset();
  442. this.requistionOrdersType = row.requistionOrdersType;
  443. const id = row.id || this.ids
  444. // 获取领料任务
  445. this.getTaskList();
  446. getRequisitionOrders(id).then(response => {
  447. this.form = response.data;
  448. // this.taskList.find(item => {
  449. // if (
  450. // this.requisitionItemsList[0].taskCode == item.saleProductsProductNumber &&// 下单重量
  451. // this.requisitionItemsList[0].saleOrderNo == item.saleProductsSaleOrderNo &&// 订单编号
  452. // this.requisitionItemsList[0].specifications == item.productionProductSpecifications // 规格
  453. // ) {
  454. // this.form.value = item.saleProductsId;
  455. // }
  456. // }
  457. // );
  458. this.requisitionItemsList = response.data.requisitionItemsList;
  459. this.open = true;
  460. this.form.taskCode = parseInt(this.form.taskCode);
  461. this.title = "修改领料单";
  462. });
  463. },
  464. /** 提交按钮 */
  465. submitForm() {
  466. if (this.requisitionItemsList.length == 0) {
  467. return this.$message.error("请添加物料信息");
  468. }
  469. let state = 0;
  470. this.requisitionItemsList.forEach(item => {
  471. if (this.form.requistionOrdersType == 0) {
  472. if (item.materialId == null || item.materialId == '') {
  473. console.log("物料信息不能为空")
  474. state = 1;
  475. }
  476. if (item.quantity == null || item.quantity == '') {
  477. console.log("数量不能为空")
  478. state = 1;
  479. }
  480. } else {
  481. // 退料
  482. if (item.actualQuantity == null || item.actualQuantity == '') {
  483. console.log("实际领料数量不能为空")
  484. state = 1;
  485. }
  486. }
  487. });
  488. if (state == 1) {
  489. return this.$message.error("请完善表单数据");
  490. }
  491. this.$refs["form"].validate(valid => {
  492. if (valid) {
  493. this.form.requisitionItemsList = this.requisitionItemsList;
  494. // 领取物料任务信息
  495. let taskInfo = this.taskList.find(item => item.saleProductsId === this.form.taskCode)
  496. // taskinfo.saleProductsLotNumber, // 生产批号
  497. // taskinfo.productionProductName // 下单产品名称
  498. this.form = {
  499. ...this.form,
  500. taskCode: taskInfo.saleProductsId,// 子表下单编号
  501. saleOrderNo: taskInfo.saleProductsSaleOrderNo,// 订单编号
  502. specifications: taskInfo.productionProductSpecifications, // 规格
  503. }
  504. if (this.form.id != null) {
  505. this.form.requistionState = this.requistionState
  506. this.form.state = this.requistionState ? 5 : this.form.state;
  507. updateRequisitionOrders(this.form).then(response => {
  508. console.log("请求成功", response);
  509. this.$modal.msgSuccess(this.requistionState ? "领料成功" : "修改成功");
  510. this.open = false;
  511. this.getList();
  512. this.requistionState = false;
  513. }).catch(reason => {
  514. console.log("catch", reason);
  515. this.$modal.msgSuccess(reason.msg());
  516. });
  517. } else {
  518. // 领料状态(0:待提交、1:审核中、2:已批准、3:未批准、4:已作废、5:已完成)
  519. this.form.state = 0
  520. this.form.requisitionNumber = Date.now();
  521. addRequisitionOrders(this.form).then(response => {
  522. this.$modal.msgSuccess("新增成功");
  523. this.open = false;
  524. this.getList();
  525. });
  526. }
  527. }
  528. });
  529. },
  530. /** 删除按钮操作 */
  531. handleDelete(row) {
  532. const ids = row.id || this.ids;
  533. this.$modal.confirm('是否确认删除领料单编号为"' + ids + '"的数据项?').then(function () {
  534. return delRequisitionOrders(ids);
  535. }).then(() => {
  536. this.getList();
  537. this.$modal.msgSuccess("删除成功");
  538. }).catch(() => {
  539. });
  540. },
  541. /** 提交审核*/
  542. submitForApproval(row) {
  543. this.$modal.confirm('是否确认提交领料单编号为"' + row.requisitionNumber + '"的领料?').then(function () {
  544. let form = {
  545. ...row,
  546. state: 1, // 0=:待提交、1:审核中、2:已批准、3:未批准、4:已作废、5:已完成
  547. dataApprovalStatus: 5, //审批状态参考字典
  548. }
  549. return approvalOrders(form);
  550. }).then(() => {
  551. this.getList();
  552. this.$modal.msgSuccess("提交成功");
  553. }).catch(() => {
  554. });
  555. },
  556. /** 领料 */
  557. requistion(row) {
  558. this.reset();
  559. const id = row.id || this.ids
  560. // 获取领料任务
  561. this.getTaskList();
  562. getRequisitionOrders(id).then(response => {
  563. this.form = response.data;
  564. this.requisitionItemsList = response.data.requisitionItemsList;
  565. this.open = true;
  566. this.form.taskCode = parseInt(this.form.taskCode);
  567. this.requistionState = true;
  568. this.title = "实际领用数量";
  569. });
  570. },
  571. /** 领料明细序号 */
  572. rowRequisitionItemsIndex({row, rowIndex}) {
  573. row.index = rowIndex + 1;
  574. },
  575. /** 领料明细添加按钮操作 */
  576. handleAddRequisitionItems() {
  577. let obj = {};
  578. obj.materialId = "";
  579. obj.quantity = "";
  580. obj.actualQuantity = "";
  581. obj.state = "";
  582. obj.specifications = "";
  583. obj.colorCode = "";
  584. obj.remark = "";
  585. obj.createById = "";
  586. obj.updateById = "";
  587. obj.dataApprovalStatus = "";
  588. obj.processKey = "";
  589. obj.taskProcessKey = "";
  590. obj.taskNodeKey = "";
  591. this.requisitionItemsList.push(obj);
  592. },
  593. /** 领料明细删除按钮操作 */
  594. handleDeleteRequisitionItems() {
  595. if (this.checkedRequisitionItems.length == 0) {
  596. this.$modal.msgError("请先选择要删除的领料明细数据");
  597. } else {
  598. const requisitionItemsList = this.requisitionItemsList;
  599. const checkedRequisitionItems = this.checkedRequisitionItems;
  600. this.requisitionItemsList = requisitionItemsList.filter(function (item) {
  601. return checkedRequisitionItems.indexOf(item.index) == -1
  602. });
  603. }
  604. },
  605. /** 复选框选中数据 */
  606. handleRequisitionItemsSelectionChange(selection) {
  607. this.checkedRequisitionItems = selection.map(item => item.index)
  608. },
  609. /** 导出按钮操作 */
  610. handleExport() {
  611. this.download('business/requisitionOrders/export', {
  612. ...this.queryParams
  613. }, `requisitionOrders_${new Date().getTime()}.xlsx`)
  614. },
  615. /**
  616. * 退料逻辑
  617. */
  618. handleRequistionState(type) {
  619. if (type == 0) {
  620. // 领料
  621. this.requisitionItemsList = [];
  622. this.requistionOrdersType = false;
  623. } else if (type == 1) {
  624. // 退料
  625. this.requistionOrdersType = true;
  626. if (this.form.taskCode) {
  627. this.requisitionItemsList = [];
  628. getRequisitionOrdersByTaskCode(this.form.taskCode).then(res => {
  629. this.requisitionItemsList = res.data.requisitionItemsList;
  630. console.log("退料详情:", res);
  631. }).catch(reason => {
  632. this.requisitionItemsList = [];
  633. });
  634. }
  635. }
  636. },
  637. handlePrint(row) {
  638. // 打印
  639. this.reset();
  640. const id = row.id || this.ids
  641. // 获取领料任务
  642. this.getTaskList();
  643. getRequisitionOrders(id).then(response => {
  644. let printlnInfo = response.data;
  645. let requisitionItemsList = response.data.requisitionItemsList;
  646. materialRequisitionTaskList().then(res => {
  647. queryMaterielList().then(qes => {
  648. let materielList = qes.data;
  649. let taskList = res.rows;
  650. let titleName = printlnInfo.requistionOrdersType == 0 ? "领料单据" : "退料单据";
  651. var tableInfo = '';
  652. for (let i = 0; i < requisitionItemsList.length; i++) {
  653. tableInfo += `
  654. <tr>
  655. <td>${i + 1}</td>
  656. <td>${requisitionItemsList[i].materialId}${materielList.find(item => item.materialCode == i.materialId).materielName}</td>
  657. <td>${requisitionItemsList[i].quantity}</td>
  658. <td>${requisitionItemsList[i].remark}</td>
  659. <td>${requisitionItemsList[i].actualQuantity}</td>
  660. </tr>`
  661. }
  662. // 模版
  663. let printContent = `
  664. <table style="border: 1px solid black;border-collapse: collapse; text-align: center; width: 100%" border="1px;">
  665. <tr>
  666. <td rowspan="2" colspan="6">${titleName}</td>
  667. </tr>
  668. <tr></tr>
  669. <tr>
  670. <td>类型</td>
  671. <td>${printlnInfo.requistionOrdersType ? '领料' : '退料'}</td>
  672. <td>任务</td>
  673. <td>${taskList.find(item => item.saleProductsId == parseInt(printlnInfo.taskCode)).saleProductsTaskName}</td>
  674. <td>日期</td>
  675. <td>${printlnInfo.requisitionDate}</td>
  676. </tr>
  677. <tr>
  678. <td>备注</td>
  679. <td colspan="5">${printlnInfo.remark}</td>
  680. </tr>
  681. </table>
  682. <div style="text-align: center;margin-bottom: 20px">
  683. <span style="position: relative;top: 20px; background: white;">物料信息</span>
  684. <hr style="clear:both;"/>
  685. </div>
  686. <table style="border: 1px solid black;border-collapse: collapse;text-align: center; width: 100%" border="1px;">
  687. <tr>
  688. <td>序号</td>
  689. <td>物料</td>
  690. <td>
  691. ${printlnInfo.requistionOrdersType ? '预计可退数量/重量' : '预计领用数量/重量'}</td>
  692. <td>备注</td>
  693. <td>${printlnInfo.requistionOrdersType ? '回退数量/重量' : '实际领用数量/重量'}</td>
  694. </tr>
  695. ` + tableInfo + `
  696. </table>`;
  697. document.body.innerHTML = document.getElementById("wuliao").innerHTML = printContent;
  698. window.print(); //打印
  699. window.location.reload();
  700. return false;
  701. });
  702. });
  703. });
  704. }
  705. }
  706. };
  707. </script>