engin_form.vue 27 KB

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