engin_form.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">工程发货申请单信息</div>
  6. </div>
  7. <div style="font-size: 12px; color: #333; margin-bottom: 20px;">注:发货申请时,库存数量为实时数量,请选择完成选择后及时保存提交,否则数量可能有变,被其他商家开单而导致库存不足。</div>
  8. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="100px" size="small" label-position="right">
  9. <el-row :gutter="20">
  10. <el-col :xs="24" :sm="12" :lg="8">
  11. <el-form-item label="发货申请单" prop="orderNum">
  12. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" readonly></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  16. <el-form-item label="单据日期" prop="orderDate">
  17. <el-date-picker
  18. v-model="mainForm.orderDate"
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%;"
  22. placeholder="选择日期">
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. </el-row>
  27. <el-row :gutter="20">
  28. <el-col :xs="24" :sm="12" :lg="8">
  29. <el-form-item label="经销商编号" prop="jxsNum">
  30. <el-input v-model="mainForm.jxsNum" readonly></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="16">
  34. <el-form-item label="经销商名称" prop="jxsName">
  35. <el-input v-model="mainForm.jxsName" readonly></el-input>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. <el-row :gutter="20">
  40. <el-col :xs="24" :sm="12" :lg="8">
  41. <el-form-item label="工程登录编号" prop="loginNum">
  42. <el-input v-model="mainForm.loginNum" placeholder="请输入工程登录编号"></el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :xs="24" :sm="12" :lg="8">
  46. <el-form-item label="工程项目名称" prop="enginName">
  47. <el-input v-model="mainForm.enginName" placeholder="请输入工程项目名称"></el-input>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :xs="24" :sm="12" :lg="8">
  51. <el-form-item label="工程登录类型" prop="loginType">
  52. <el-input v-model="mainForm.loginType" placeholder="请输入工程登录类型"></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="24" :sm="12" :lg="8">
  56. <el-form-item label="厂工程编号" prop="factoryNum">
  57. <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编号"></el-input>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :xs="24" :sm="12" :lg="8">
  61. <el-form-item label="使用单位" prop="company">
  62. <el-input v-model="mainForm.company" placeholder="请输入使用单位"></el-input>
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. <el-row :gutter="20">
  67. <el-col :xs="24" :sm="12" :lg="8">
  68. <el-form-item label="联系人" prop="contactMan">
  69. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人" readonly></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :xs="24" :sm="12" :lg="8">
  73. <el-form-item label="固定电话" prop="tel">
  74. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" readonly></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :xs="24" :sm="12" :lg="8">
  78. <el-form-item label="移动电话" prop="phone">
  79. <el-input v-model="mainForm.phone" placeholder="请输入移动电话" readonly></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :xs="24" :sm="24" :lg="24">
  83. <el-form-item label="安装地址" prop="address">
  84. <el-input v-model="mainForm.address" placeholder="请输入安装地址"></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :xs="24" :sm="24" :lg="24">
  88. <el-form-item label="备注" prop="remark">
  89. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row :gutter="20">
  94. <el-col :xs="24" :sm="8" :lg="8">
  95. <el-form-item label="附件" prop="fileUrl">
  96. <fileUpload :fileList="fileList" />
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row :gutter="20">
  101. <el-col :xs="24" :sm="12" :lg="8">
  102. <el-form-item label="制单人" prop="createMan">
  103. <el-input v-model="mainForm.createMan" readonly></el-input>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  107. <el-form-item label="制单日期" prop="createDate">
  108. <el-date-picker
  109. v-model="mainForm.createDate"
  110. readonly
  111. type="datetime"
  112. value-format="yyyy-MM-dd hh:mm:ss"
  113. style="width: 100%;"
  114. placeholder="选择日期">
  115. </el-date-picker>
  116. </el-form-item>
  117. </el-col>
  118. </el-row>
  119. </el-form>
  120. <div class="main-title">
  121. <div class="title">货品信息</div>
  122. <div>
  123. <span style="font-size: 14px; margin-right: 10px">仓库</span>
  124. <el-select v-model="screenForm.warehouse" placeholder="请选择发货仓库" size="small" filterable clearable :disabled="goodsList.length > 0">
  125. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  126. </el-select>
  127. <el-divider direction="vertical"></el-divider>
  128. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加引用</el-button>
  129. </div>
  130. </div>
  131. <div class="table" style="margin-top: 20px">
  132. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  133. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  134. <el-table-column align="center" label="引用单号" prop="enginOrderNo" min-width="180" show-overflow-tooltip></el-table-column>
  135. <el-table-column align="center" label="单号类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  136. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  137. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  138. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  139. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  140. <el-table-column align="center" label="数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  141. <template slot-scope="scope">
  142. <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
  143. </template>
  144. </el-table-column>
  145. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  146. <template slot-scope="scope">
  147. <el-input v-model="scope.row.remark" size="small"></el-input>
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="center" label="操作" width="100" fixed="right">
  151. <template slot-scope="scope">
  152. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. <div class="page-footer">
  158. <div class="footer" :class="classObj">
  159. <el-button type="primary" @click="clickSubmitForm('SAVE')">保 存</el-button>
  160. <el-button type="primary" @click="clickSubmitForm('WAIT')">提交审核</el-button>
  161. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  162. <el-button slot="reference">关 闭</el-button>
  163. </el-popconfirm>
  164. </div>
  165. </div>
  166. <el-dialog title="添加产品" :visible.sync="isShowDialog" width="80%">
  167. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left" label-width="100px">
  168. <el-row :gutter="20">
  169. <el-col :xs="12" :sm="12" :lg="6">
  170. <el-form-item prop="loginNum" label="工程登录编号">
  171. <el-input v-model="screenForm.loginNum" placeholder="请输入工程登录编号"></el-input>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :xs="12" :sm="12" :lg="6">
  175. <el-form-item prop="enginName" label="工程名称">
  176. <el-input v-model="screenForm.enginName" placeholder="请输入工程名称"></el-input>
  177. </el-form-item>
  178. </el-col>
  179. <el-col :xs="12" :sm="12" :lg="6">
  180. <el-form-item prop="model" label="规格型号">
  181. <el-input v-model="screenForm.model" placeholder="请输入规格型号"></el-input>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :xs="12" :sm="12" :lg="6">
  185. <el-form-item label="发货申请日期" prop="date">
  186. <el-date-picker
  187. v-model="screenForm.date"
  188. type="datetimerange"
  189. range-separator="至"
  190. style="width: 100%; height: 33px"
  191. value-format="yyyy-MM-dd HH:mm:ss"
  192. start-placeholder="开始日期"
  193. end-placeholder="结束日期">
  194. </el-date-picker>
  195. </el-form-item>
  196. </el-col>
  197. <el-col :xs="12" :sm="12" :lg="6">
  198. <el-form-item prop="warehouse" label="选择仓库">
  199. <el-select v-model="screenForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable :disabled="goodsList.length > 0 || tableSelection.length > 0">
  200. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  201. </el-select>
  202. </el-form-item>
  203. </el-col>
  204. <el-col :xs="12" :sm="12" :lg="18" class="tr">
  205. <el-form-item label="">
  206. <el-button size="small" @click="resetScreenForm">清空</el-button>
  207. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  208. </el-form-item>
  209. </el-col>
  210. </el-row>
  211. </el-form>
  212. <div class="table">
  213. <el-table :data="tableGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="tableSelectionChange">
  214. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  215. <el-table-column align="center" label="订单类型" prop="orderType" min-width="180" show-overflow-tooltip>
  216. <template slot-scope="scope">
  217. {{scope.row.orderType | orderTypeFilter}}
  218. </template>
  219. </el-table-column>
  220. <el-table-column align="center" label="工程登录编号" prop="enginOrderNo" min-width="200" show-overflow-tooltip></el-table-column>
  221. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  222. <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  223. <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
  224. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  225. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  226. <el-table-column align="center" label="单位" prop="unit" min-width="80" show-overflow-tooltip></el-table-column>
  227. <el-table-column align="center" label="订单数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
  228. <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
  229. <el-table-column align="center" label="已申请未出货数量" prop="sendQty" min-width="100" show-overflow-tooltip></el-table-column>
  230. <el-table-column align="center" label="未申请数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  231. <el-table-column align="center" label="本次申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  232. <template slot-scope="scope">
  233. <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
  234. </template>
  235. </el-table-column>
  236. <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
  237. <template slot-scope="scope">
  238. {{stockFilter(scope.row, 1)}}
  239. </template>
  240. </el-table-column>
  241. <el-table-column align="center" label="对应库存数量" prop="stockCorrespond" min-width="110" show-overflow-tooltip>
  242. <template slot-scope="scope">
  243. {{stockFilter(scope.row, 1)}}
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. <div class="pagination clearfix" style="margin-top: 10px">
  248. <div class="fr">
  249. <el-pagination
  250. @current-change="handleTableCurrentChange"
  251. :current-page="currentPage"
  252. :page-size="10"
  253. background
  254. layout="prev, pager, next"
  255. :total="listTotal">
  256. </el-pagination>
  257. </div>
  258. </div>
  259. </div>
  260. <span slot="footer" class="dialog-footer">
  261. <el-button @click="closeDialog">取 消</el-button>
  262. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  263. </span>
  264. </el-dialog>
  265. </div>
  266. </template>
  267. <script>
  268. import { getEnginDetail, addEngin, editEngin, getEnginGoodsList, getWarehouseList, getDealerList, getEnginGoodsDetail } from "@/api/supply/apply";
  269. import { getDictList } from '@/api/common'
  270. import { findElem } from '@/utils/util'
  271. import fileUpload from '@/components/Common/file-upload.vue'
  272. export default {
  273. components: {
  274. fileUpload
  275. },
  276. name: 'EnginForm',
  277. componentName: 'EnginForm',
  278. props: ['listItem'],
  279. filters: {
  280. orderTypeFilter(val) {
  281. const MAP = {
  282. TRADE: '商用',
  283. HOME: '家用',
  284. RETAIL: '零售单',
  285. RETAIL_POLICY: '销售政策单',
  286. PERMU_HOME: '置换单家用',
  287. PERMU_TRADE: '置换商用',
  288. PERMU_RETAIL: '置换零售',
  289. PERMU_RETAIL_POLICY: '置换销售政策单',
  290. }
  291. return MAP[val];
  292. },
  293. },
  294. data() {
  295. return {
  296. mainForm: {
  297. orderNum: '',
  298. orderDate: '',
  299. jxsNum: '',
  300. jxsName: '',
  301. loginNum: '',
  302. enginName: '',
  303. loginType: '',
  304. factoryNum: '',
  305. company: '',
  306. contactMan: '',
  307. tel: '',
  308. phone: '',
  309. address: '',
  310. remark: '',
  311. createMan: '',
  312. createDate: '',
  313. },
  314. mainFormRules: {
  315. orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  316. },
  317. dealerList: [],
  318. fileList: [],
  319. goodsList: [],
  320. warehouseList: [],
  321. isShowDialog: false,
  322. screenForm: {
  323. loginNum: '',
  324. enginName: '',
  325. model: '',
  326. date: '',
  327. warehouse: '',
  328. },
  329. currentPage: 1,
  330. listTotal: 0,
  331. typeList: [],
  332. stockList: [],
  333. tableGoodsList: [],
  334. tableSelection: [],
  335. }
  336. },
  337. computed: {
  338. sidebar() {
  339. return this.$store.state.app.sidebar
  340. },
  341. classObj() {
  342. return {
  343. hideSidebar: !this.sidebar.opened,
  344. openSidebar: this.sidebar.opened
  345. }
  346. },
  347. },
  348. created() {
  349. this.getDictList();
  350. this.getWarehouseList();
  351. this.getDealerList();
  352. if(this.listItem) {
  353. this.getDetail();
  354. }else {
  355. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerId;
  356. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  357. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  358. this.mainForm.createDate = this.getDate();
  359. }
  360. },
  361. methods: {
  362. // 返回列表
  363. goBack() {
  364. this.$emit('backListFormDetail');
  365. },
  366. getDate() {
  367. var date = new Date();
  368. var seperator1 = "-";
  369. var year = date.getFullYear();
  370. var month = date.getMonth() + 1;
  371. var strDate = date.getDate();
  372. if (month >= 1 && month <= 9) {
  373. month = "0" + month;
  374. }
  375. if (strDate >= 0 && strDate <= 9) {
  376. strDate = "0" + strDate;
  377. }
  378. var currentdate = year + seperator1 + month + seperator1 + strDate;
  379. return currentdate;
  380. },
  381. // 获取详情
  382. getDetail() {
  383. getEnginDetail({id: this.listItem.id}).then(res => {
  384. let data = res.data;
  385. this.mainForm.orderNum = data.id;
  386. this.mainForm.orderDate = data.orderTime.slice(0, 10);
  387. this.mainForm.jxsNum = data.customerNumber;
  388. this.mainForm.jxsName = data.customerName;
  389. this.mainForm.loginNum = data.enginOrderNo;
  390. this.mainForm.enginName = data.refProjectName;
  391. this.mainForm.loginType = data.enginOrderType;
  392. this.mainForm.factoryNum = data.refFactoryNo;
  393. this.mainForm.company = data.refUseUnit;
  394. this.mainForm.saleType = data.saleTypeId;
  395. this.mainForm.contactMan = data.refLinkman;
  396. this.mainForm.tel = data.refTel;
  397. this.mainForm.phone = data.refPhone;
  398. this.mainForm.address = data.refInstallAddress;
  399. this.mainForm.createMan = data.createBy;
  400. this.mainForm.createDate = data.createTime;
  401. this.mainForm.remark = data.remark;
  402. this.screenForm.warehouse = data.correspondId;
  403. this.fileList = data.fileUrl ? [{
  404. url: data.fileUrl,
  405. name: data.fileName,
  406. }] : [];
  407. // data.orders.forEach(item => {
  408. // item.orderId = item.id;
  409. // })
  410. this.goodsList = data.orders;
  411. })
  412. },
  413. // 获取仓库列表
  414. getWarehouseList() {
  415. getWarehouseList({
  416. pageNum: 1,
  417. pageSize: -1
  418. }).then((res) => {
  419. this.warehouseList = res.data.records;
  420. })
  421. },
  422. getDictList() {
  423. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  424. this.typeList = res.data;
  425. })
  426. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  427. this.stockList = res.data;
  428. })
  429. },
  430. // 获取经销商列表
  431. getDealerList() {
  432. getDealerList({
  433. pageNum: 1,
  434. pageSize: -1,
  435. bindUser: false
  436. }).then(res => {
  437. this.dealerList = res.data.records;
  438. })
  439. },
  440. // 库存字段
  441. stockFilter(item, type) {
  442. let STOCK_ORDER_INVOICE = this.stockList.find(o => o.dictCode == 'STOCK_ORDER_INVOICE').dictValue;
  443. if(type === 1) {
  444. return item.stockAdequate > STOCK_ORDER_INVOICE ? '充足' : item.stockAdequate;
  445. }
  446. if(type === 2) {
  447. return item.stockCorrespond > STOCK_ORDER_INVOICE ? '充足' : item.stockCorrespond;
  448. }
  449. },
  450. // 获取商品列表
  451. getGoodsList() {
  452. getEnginGoodsList({
  453. pageNum: this.currentPage,
  454. pageSize: 10,
  455. enginOrderNo: this.screenForm.loginNum,
  456. refProjectName: this.screenForm.enginName,
  457. specification: this.screenForm.model,
  458. startTime: this.screenForm.date ? this.screenForm.date[0] : '',
  459. endTime: this.screenForm.date ? this.screenForm.date[1] : '',
  460. correspondId: this.screenForm.warehouse,
  461. }).then(res => {
  462. let oldGoodsList = this.goodsList;
  463. let newGoodsList = res.data.records;
  464. for(let i = 0; i < oldGoodsList.length; i++) {
  465. let oldItem = oldGoodsList[i]
  466. for(let j = 0; j < newGoodsList.length; j++) {
  467. let newItem = newGoodsList[j]
  468. if(newItem.orderId === oldItem.orderId){
  469. newGoodsList[j].selected = true;
  470. break;
  471. }
  472. }
  473. }
  474. this.tableGoodsList = newGoodsList;
  475. this.listTotal = res.data.total;
  476. })
  477. },
  478. // 查询重复值并禁选
  479. checkboxSelect(row, rowIndex) {
  480. if (row.selected) {
  481. return false // 禁用
  482. }else{
  483. return true // 不禁用
  484. }
  485. },
  486. // 点击 选择商品
  487. openDialog() {
  488. if(!this.screenForm.warehouse) {
  489. return this.$errorMsg('请选择仓库');
  490. }
  491. this.isShowDialog = true;
  492. this.getGoodsList();
  493. },
  494. // 提交筛选表单
  495. submitScreenForm() {
  496. if(!this.screenForm.warehouse) {
  497. return this.$errorMsg('请选择仓库');
  498. }
  499. this.currentPage = 1;
  500. this.getGoodsList();
  501. },
  502. // 重置筛选表单
  503. resetScreenForm() {
  504. this.$refs.screenForm.resetFields();
  505. this.currentPage = 1;
  506. this.tableGoodsList = [];
  507. // this.getGoodsList();
  508. },
  509. // 更改列表当前页
  510. handleTableCurrentChange(val) {
  511. if(this.tableSelection.length > 0) {
  512. return this.$errorMsg('已选择产品不可切换');
  513. }
  514. this.currentPage = val;
  515. this.getGoodsList();
  516. },
  517. // 关闭 弹窗
  518. closeDialog() {
  519. this.isShowDialog = false;
  520. },
  521. // 列表选择
  522. tableSelectionChange(val) {
  523. this.tableSelection = val;
  524. },
  525. // 数组去重
  526. delRepeat(arr1, arr2) {
  527. let allArr = arr1.concat(arr2); // 两个数组对象合并
  528. let newArr = []; // 存放去重后数据的新数组
  529. for(let i=0; i<allArr.length; i++){ // 循环allArr数组对象的内容
  530. let flag = true; // 建立标记,判断数据是否重复,true为不重复
  531. for(let j=0; j<newArr.length; j++){ // 循环新数组的内容
  532. if(allArr[i].orderId == newArr[j].orderId){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  533. flag = false;
  534. }
  535. }
  536. if(flag){ // 判断是否重复
  537. newArr.push(allArr[i]); // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  538. }
  539. }
  540. return newArr;
  541. },
  542. // 检查是否一致
  543. isAllEqual(array) {
  544. if (array.length > 0) {
  545. return !array.some(function(item, index) {
  546. return item.enginOrderNo !== array[0].enginOrderNo;
  547. });
  548. } else {
  549. return true;
  550. }
  551. },
  552. // 确定 添加产品
  553. submitAddGoods() {
  554. let list = this.goodsList.concat(this.tableSelection);
  555. if(!this.isAllEqual(list)) {
  556. return this.$errorMsg('只能选择同一个工程编号的订单');
  557. }
  558. for(let i=0; i<this.tableSelection.length; i++) {
  559. if(!this.tableSelection[i].invoiceNum) {
  560. this.$errorMsg('请输入申请数量');
  561. return;
  562. }
  563. if(this.tableSelection[i].invoiceNum > this.tableSelection[i].refundableQty) {
  564. this.$errorMsg('申请数量不能大于未申请数量');
  565. return;
  566. }
  567. }
  568. // let allList = this.tableGoodsList;
  569. // let selectList = this.tableSelection;
  570. // let submitList = [];
  571. // for(let i = 0; i < allList.length; i++) {
  572. // for(let j = 0; j < selectList.length; j++) {
  573. // if(selectList[j].enginOrderNo == allList[i].enginOrderNo){
  574. // submitList.push(allList[i]);
  575. // }
  576. // }
  577. // }
  578. // this.goodsList = this.delRepeat(submitList, this.goodsList);
  579. this.isShowDialog = false;
  580. this.tableGoodsList = [];
  581. this.goodsList = this.goodsList.concat(this.tableSelection);
  582. this.getEnginGoodsDetail(this.tableSelection[0].enginOrderNo);
  583. // this.getEnginGoodsDetail(submitList[0].enginOrderNo);
  584. },
  585. getEnginGoodsDetail(enginOrderNo) {
  586. getEnginGoodsDetail({enginOrderNo}).then(res => {
  587. let data = res.data;
  588. this.mainForm.loginNum = data.refEnginRecordNo;
  589. this.mainForm.enginName = data.refProjectName;
  590. this.mainForm.loginType = data.refPromiseStatus;
  591. this.mainForm.factoryNum = data.refFactoryNo;
  592. this.mainForm.company = data.refUseUnit;
  593. this.mainForm.saleType = data.saleTypeId;
  594. this.mainForm.contactMan = data.refLinkman;
  595. this.mainForm.tel = data.refTel;
  596. this.mainForm.phone = data.refPhone;
  597. this.mainForm.address = data.refInstallAddress;
  598. })
  599. },
  600. // 删除产品
  601. deleteItem(index) {
  602. this.goodsList.splice(index, 1);
  603. // this.goodsList = this.goodsList.filter((item) => {
  604. // return item.orderId != id
  605. // })
  606. },
  607. // 保存
  608. clickSubmitForm(status) {
  609. this.$refs.mainForm.validate((valid) => {
  610. if (valid) {
  611. if(this.goodsList.length < 1) {
  612. return this.$errorMsg('请添加引用');
  613. }
  614. for(let i=0; i<this.goodsList.length; i++) {
  615. if(!this.goodsList[i].invoiceNum) {
  616. this.$errorMsg('请输入申请数量');
  617. return;
  618. }
  619. if(this.goodsList[i].invoiceNum > this.goodsList[i].refundableQty) {
  620. this.$errorMsg('申请数量不能大于未申请数量');
  621. return;
  622. }
  623. }
  624. if(!this.screenForm.warehouse) {
  625. return this.$errorMsg('请选择仓库');
  626. }
  627. let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
  628. let params = {
  629. orderTime: this.mainForm.orderDate + ' 00:00:00',
  630. remark: this.mainForm.remark,
  631. enginOrderNo: this.mainForm.loginNum,
  632. refProjectName: this.mainForm.enginName,
  633. enginOrderType: this.mainForm.loginType,
  634. refFactoryNo: this.mainForm.factoryNum,
  635. refUseUnit: this.mainForm.company,
  636. refLinkman: this.mainForm.contactMan,
  637. refTel: this.mainForm.tel,
  638. refPhone: this.mainForm.phone,
  639. refInstallAddress: this.mainForm.address,
  640. remark: this.mainForm.remark,
  641. fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
  642. fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
  643. correspondId: this.screenForm.warehouse,
  644. correspondName,
  645. orders: this.goodsList,
  646. examineStatus: status,
  647. }
  648. if(this.listItem) {
  649. params.id = this.listItem.id;
  650. editEngin(params).then(res => {
  651. this.$successMsg('编辑成功');
  652. this.goBack();
  653. this.$parent.getList();
  654. })
  655. }else {
  656. addEngin(params).then(res => {
  657. this.$successMsg('添加成功');
  658. this.goBack();
  659. this.$parent.getList();
  660. })
  661. }
  662. }
  663. })
  664. },
  665. }
  666. }
  667. </script>
  668. <style scoped lang="scss">
  669. .detail-container {
  670. width: 100%;
  671. height: 100%;
  672. }
  673. .main-title {
  674. display: flex;
  675. justify-content: space-between;
  676. align-items: center;
  677. margin-top: 20px;
  678. height: 60px;
  679. border-bottom: 1px solid #DCDFE6;
  680. margin-bottom: 20px;
  681. .title {
  682. font-size: 16px;
  683. font-weight: 600;
  684. padding-left: 10px;
  685. }
  686. }
  687. </style>