engin_form.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  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">
  8. 注:发货申请时,库存数量为实时数量,请选择完成选择后及时保存提交,否则数量可能有变,被其他商家开单而导致库存不足。
  9. </div>
  10. <el-form
  11. ref="mainForm"
  12. :model="mainForm"
  13. :rules="mainFormRules"
  14. label-width="100px"
  15. size="small"
  16. label-position="right"
  17. >
  18. <el-row :gutter="20">
  19. <el-col :xs="24" :sm="12" :lg="8">
  20. <el-form-item label="发货申请单" prop="orderNum">
  21. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  25. <el-form-item label="单据日期" prop="orderDate">
  26. <el-date-picker
  27. v-model="mainForm.orderDate"
  28. disabled
  29. type="date"
  30. value-format="yyyy-MM-dd"
  31. style="width: 100%"
  32. placeholder="选择日期"
  33. >
  34. </el-date-picker>
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. <el-row :gutter="20">
  39. <el-col :xs="24" :sm="12" :lg="8">
  40. <el-form-item label="经销商编号" prop="jxsNum">
  41. <el-input v-model="mainForm.jxsNum" disabled></el-input>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :xs="24" :sm="12" :lg="16">
  45. <el-form-item label="经销商名称" prop="jxsName">
  46. <el-input v-model="mainForm.jxsName" disabled></el-input>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <el-row :gutter="20">
  51. <el-col :xs="24" :sm="12" :lg="8">
  52. <el-form-item label="工程登录编号" prop="loginNum">
  53. <div style="display: flex">
  54. <el-input v-model="mainForm.loginNum" :disabled="isDealer" placeholder="请输入工程登录编号"></el-input>
  55. <el-button style="margin-left: 10px" @click="openDialog">引用</el-button>
  56. </div>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :xs="24" :sm="12" :lg="8">
  60. <el-form-item label="家用项目类别" prop="enginName">
  61. <el-input v-model="mainForm.enginName" placeholder="请输入家用项目类别" :disabled="isDealer"></el-input>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :xs="24" :sm="12" :lg="8">
  65. <el-form-item label="商用项目名称" prop="refProjectName">
  66. <el-input
  67. v-model="mainForm.refProjectName"
  68. placeholder="请输入商用项目名称"
  69. :disabled="isDealer"
  70. ></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :xs="24" :sm="12" :lg="8">
  74. <el-form-item label="工程登录类型" prop="loginType">
  75. <el-input v-model="mainForm.loginType" 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="factoryNum">
  80. <el-input v-model="mainForm.factoryNum" placeholder="请输入跨厂区编号" disabled></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :xs="24" :sm="12" :lg="8">
  84. <el-form-item label="使用单位" prop="company">
  85. <el-input v-model="mainForm.company" placeholder="请输入使用单位" disabled></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :xs="24" :sm="12" :lg="8">
  89. <el-form-item label="文件编号" prop="fileNo">
  90. <el-input v-model="mainForm.fileNo" placeholder="请输入文件编号" disabled></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :xs="24" :sm="12" :lg="8">
  94. <el-form-item label="行业类别" prop="refTradeCategory">
  95. <el-input v-model="mainForm.refTradeCategory" placeholder="请输入文件编号" :disabled="isDealer"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <!-- <el-col :xs="24" :sm="12" :lg="8">
  99. <el-form-item label="项目类型" prop="refTradeCategory">
  100. <el-input v-model="mainForm.refTradeCategory" placeholder="请输入文件编号" disabled></el-input>
  101. </el-form-item>
  102. </el-col> -->
  103. </el-row>
  104. <el-row :gutter="20">
  105. <el-col :xs="24" :sm="12" :lg="8">
  106. <el-form-item label="联系人" prop="contactMan">
  107. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人" disabled></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :xs="24" :sm="12" :lg="8">
  111. <el-form-item label="固定电话" prop="tel">
  112. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" disabled></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :xs="24" :sm="12" :lg="8">
  116. <el-form-item label="移动电话" prop="phone">
  117. <el-input v-model="mainForm.phone" placeholder="请输入移动电话" disabled></el-input>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :xs="24" :sm="24" :lg="24">
  121. <el-form-item label="安装地址" prop="address">
  122. <el-input v-model="mainForm.address" placeholder="请输入安装地址" disabled></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :xs="24" :sm="24" :lg="24">
  126. <el-form-item label="备注" prop="remark">
  127. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row :gutter="20">
  132. <el-col :xs="24" :sm="8" :lg="8">
  133. <el-form-item label="附件" prop="fileUrl">
  134. <fileUpload :fileList="fileList" multiple />
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. <el-row :gutter="20">
  139. <el-col :xs="24" :sm="12" :lg="8">
  140. <el-form-item label="制单人" prop="createMan">
  141. <el-input v-model="mainForm.createMan" disabled></el-input>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  145. <el-form-item label="制单日期" prop="createDate">
  146. <el-date-picker
  147. v-model="mainForm.createDate"
  148. disabled
  149. type="datetime"
  150. value-format="yyyy-MM-dd hh:mm:ss"
  151. style="width: 100%"
  152. placeholder="选择日期"
  153. >
  154. </el-date-picker>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :xs="24" :sm="24" :lg="24" v-if="mainForm.examineRemark">
  158. <el-form-item label="审批说明" prop="examineRemark">
  159. <el-input v-model="mainForm.examineRemark" placeholder="请输入审批说明" disabled></el-input>
  160. </el-form-item>
  161. </el-col>
  162. </el-row>
  163. </el-form>
  164. <div class="main-title">
  165. <div class="title">货品信息</div>
  166. </div>
  167. <div class="table" style="margin-top: 20px">
  168. <el-table
  169. :data="goodsList"
  170. element-loading-text="Loading"
  171. border
  172. fit
  173. highlight-current-row
  174. stripe
  175. max-height="400"
  176. >
  177. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  178. <el-table-column
  179. align="center"
  180. label="引用单号"
  181. prop="enginOrderNo"
  182. min-width="180"
  183. show-overflow-tooltip
  184. ></el-table-column>
  185. <el-table-column
  186. align="center"
  187. label="单号类型"
  188. prop="saleTypeName"
  189. min-width="100"
  190. show-overflow-tooltip
  191. ></el-table-column>
  192. <el-table-column
  193. align="center"
  194. label="销售类型"
  195. prop="saleTypeName"
  196. min-width="100"
  197. show-overflow-tooltip
  198. ></el-table-column>
  199. <el-table-column
  200. align="center"
  201. label="物料编码"
  202. prop="materialCode"
  203. min-width="120"
  204. show-overflow-tooltip
  205. ></el-table-column>
  206. <el-table-column
  207. align="center"
  208. label="产品编码"
  209. prop="materialOldNumber"
  210. min-width="120"
  211. show-overflow-tooltip
  212. ></el-table-column>
  213. <el-table-column
  214. align="center"
  215. label="产品名称"
  216. prop="materialName"
  217. min-width="160"
  218. show-overflow-tooltip
  219. ></el-table-column>
  220. <el-table-column
  221. align="center"
  222. label="规格型号"
  223. prop="specification"
  224. min-width="160"
  225. show-overflow-tooltip
  226. ></el-table-column>
  227. <el-table-column
  228. align="center"
  229. label="单位"
  230. prop="unit"
  231. min-width="100"
  232. show-overflow-tooltip
  233. ></el-table-column>
  234. <el-table-column align="center" label="数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  235. <template slot-scope="scope">
  236. <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
  237. </template>
  238. </el-table-column>
  239. <el-table-column align="center" label="表头备注" prop="headerRemark" min-width="160" show-overflow-tooltip>
  240. <template slot-scope="scope">
  241. <el-input v-model="scope.row.headerRemark" size="small"></el-input>
  242. </template>
  243. </el-table-column>
  244. <el-table-column align="center" label="表体备注" prop="invoiceRemark" min-width="160" show-overflow-tooltip>
  245. <template slot-scope="scope">
  246. <el-input v-model="scope.row.invoiceRemark" size="small"></el-input>
  247. </template>
  248. </el-table-column>
  249. <el-table-column align="center" label="操作" width="100" fixed="right">
  250. <template slot-scope="scope">
  251. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  252. </template>
  253. </el-table-column>
  254. </el-table>
  255. </div>
  256. <div class="page-footer">
  257. <div class="footer" :class="classObj">
  258. <!-- <el-button type="primary" @click="clickSubmitForm('SAVE')">保 存</el-button> -->
  259. <el-button type="primary" @click="clickSubmitForm('WAIT')">提交审核</el-button>
  260. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px">
  261. <el-button slot="reference">返回列表</el-button>
  262. </el-popconfirm>
  263. </div>
  264. </div>
  265. <el-dialog title="添加引用" append-to-body :visible.sync="isShowDialog" width="80%">
  266. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left" label-width="100px">
  267. <el-row :gutter="20">
  268. <el-col :xs="12" :sm="12" :lg="6">
  269. <el-form-item prop="loginNum" label="工程登录编号">
  270. <el-input v-model="screenForm.loginNum" placeholder="请输入工程登录编号"></el-input>
  271. </el-form-item>
  272. </el-col>
  273. <el-col :xs="12" :sm="12" :lg="6">
  274. <el-form-item prop="enginName" label="家用项目类别">
  275. <el-input v-model="screenForm.enginName" placeholder="请输入家用项目类别"></el-input>
  276. </el-form-item>
  277. </el-col>
  278. <!-- <el-col :xs="24" :sm="12" :lg="8">
  279. <el-form-item label="商用项项目名称" prop="refProjectName">
  280. <el-input v-model="screenForm.refProjectName" placeholder="请输入家用项目类别" :disabled="isDealer"></el-input>
  281. </el-form-item>
  282. </el-col> -->
  283. <el-col :xs="12" :sm="12" :lg="6">
  284. <el-form-item prop="model" label="规格型号">
  285. <el-input v-model="screenForm.model" placeholder="请输入规格型号"></el-input>
  286. </el-form-item>
  287. </el-col>
  288. <el-col :xs="12" :sm="12" :lg="6">
  289. <el-form-item label="发货申请日期" prop="date">
  290. <el-date-picker
  291. v-model="screenForm.date"
  292. type="datetimerange"
  293. :default-time="['00:00:00', '23:59:59']"
  294. range-separator="至"
  295. style="width: 100%; height: 33px"
  296. value-format="yyyy-MM-dd HH:mm:ss"
  297. start-placeholder="开始日期"
  298. end-placeholder="结束日期"
  299. >
  300. </el-date-picker>
  301. </el-form-item>
  302. </el-col>
  303. <el-col :xs="12" :sm="12" :lg="6">
  304. <el-form-item prop="warehouse" label="选择仓库">
  305. <el-select
  306. v-model="screenForm.warehouse"
  307. placeholder="请选择仓库"
  308. size="small"
  309. filterable
  310. clearable
  311. :disabled="goodsList.length > 0 || tableSelection.length > 0"
  312. style="width: 100%"
  313. >
  314. <el-option
  315. :label="item.name"
  316. :value="item.id"
  317. v-for="(item, index) in warehouseList"
  318. :key="index"
  319. ></el-option>
  320. </el-select>
  321. </el-form-item>
  322. </el-col>
  323. <el-col :xs="12" :sm="6" :lg="6">
  324. <el-form-item prop="type" label="存货类别">
  325. <el-select
  326. v-model="screenForm.type"
  327. placeholder="选择存货类别"
  328. style="width: 100%"
  329. :disabled="goodsList.length > 0"
  330. >
  331. <el-option
  332. v-for="item in categoryList"
  333. :key="item.name"
  334. :label="item.name"
  335. :value="item.name"
  336. ></el-option>
  337. </el-select>
  338. </el-form-item>
  339. </el-col>
  340. <el-col :xs="12" :sm="12" :lg="12" class="tr">
  341. <el-form-item label="">
  342. <el-button size="small" @click="resetScreenForm">清空</el-button>
  343. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  344. </el-form-item>
  345. </el-col>
  346. </el-row>
  347. </el-form>
  348. <div class="table">
  349. <el-table
  350. :data="tableGoodsList"
  351. element-loading-text="Loading"
  352. border
  353. fit
  354. highlight-current-row
  355. stripe
  356. height="400"
  357. @selection-change="tableSelectionChange"
  358. >
  359. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect"></el-table-column>
  360. <el-table-column align="center" label="新旧单标识" prop="mainOrderId" min-width="140" show-overflow-tooltip>
  361. <template slot-scope="scope">
  362. {{ scope.row.orderBase == 1 ? '新单' : '旧单' }}
  363. </template>
  364. </el-table-column>
  365. <el-table-column align="center" label="订单类型" prop="orderType" min-width="180" show-overflow-tooltip>
  366. <template slot-scope="scope">
  367. {{ scope.row.orderType | orderTypeFilter }}
  368. </template>
  369. </el-table-column>
  370. <el-table-column
  371. align="center"
  372. label="工程登录编号"
  373. prop="refEnginRecordNo"
  374. min-width="200"
  375. show-overflow-tooltip
  376. ></el-table-column>
  377. <!-- <el-table-column align="center" label="表头登录类型" prop="refPromiseStatus" min-width="200" show-overflow-tooltip></el-table-column>
  378. <el-table-column align="center" label="项目类别" prop="refProjectCategory" min-width="200" show-overflow-tooltip></el-table-column>
  379. <el-table-column align="center" label="行业类别" prop="refTradeCategory" min-width="200" show-overflow-tooltip></el-table-column> -->
  380. <el-table-column
  381. align="center"
  382. label="销售类型"
  383. prop="saleTypeName"
  384. min-width="100"
  385. show-overflow-tooltip
  386. ></el-table-column>
  387. <el-table-column
  388. align="center"
  389. label="物料编码"
  390. prop="materialCode"
  391. min-width="120"
  392. show-overflow-tooltip
  393. ></el-table-column>
  394. <el-table-column
  395. align="center"
  396. label="产品编码"
  397. prop="materialOldNumber"
  398. min-width="120"
  399. show-overflow-tooltip
  400. ></el-table-column>
  401. <el-table-column
  402. align="center"
  403. label="产品名称"
  404. prop="materialName"
  405. min-width="160"
  406. show-overflow-tooltip
  407. ></el-table-column>
  408. <el-table-column
  409. align="center"
  410. label="规格型号"
  411. prop="specification"
  412. min-width="160"
  413. show-overflow-tooltip
  414. ></el-table-column>
  415. <el-table-column
  416. align="center"
  417. label="单位"
  418. prop="unit"
  419. min-width="80"
  420. show-overflow-tooltip
  421. ></el-table-column>
  422. <el-table-column
  423. align="center"
  424. label="订单数量"
  425. prop="qty"
  426. min-width="80"
  427. show-overflow-tooltip
  428. ></el-table-column>
  429. <el-table-column
  430. align="center"
  431. label="已申请数量"
  432. prop="alreadyInvoiceNum"
  433. min-width="100"
  434. show-overflow-tooltip
  435. ></el-table-column>
  436. <el-table-column
  437. align="center"
  438. label="已申请未出货数量"
  439. prop="sendQty"
  440. min-width="100"
  441. show-overflow-tooltip
  442. ></el-table-column>
  443. <el-table-column
  444. align="center"
  445. label="未申请数量"
  446. prop="refundableQty"
  447. min-width="100"
  448. show-overflow-tooltip
  449. ></el-table-column>
  450. <el-table-column align="center" label="本次申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  451. <template slot-scope="scope">
  452. <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
  453. </template>
  454. </el-table-column>
  455. <!-- <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
  456. <template slot-scope="scope">
  457. {{stockFilter(scope.row, 1)}}
  458. </template>
  459. </el-table-column> -->
  460. <el-table-column
  461. align="center"
  462. label="对应库存数量"
  463. prop="stockCorrespond"
  464. min-width="110"
  465. show-overflow-tooltip
  466. >
  467. <template slot-scope="scope">
  468. {{ stockFilter(scope.row, 2) }}
  469. </template>
  470. </el-table-column>
  471. </el-table>
  472. <div class="pagination clearfix" style="margin-top: 10px">
  473. <div class="fr">
  474. <el-pagination
  475. @current-change="handleTableCurrentChange"
  476. :current-page="currentPage"
  477. :page-size="10"
  478. background
  479. layout="prev, pager, next"
  480. :total="listTotal"
  481. >
  482. </el-pagination>
  483. </div>
  484. </div>
  485. </div>
  486. <span slot="footer" class="dialog-footer">
  487. <el-button @click="closeDialog">取 消</el-button>
  488. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  489. </span>
  490. </el-dialog>
  491. </div>
  492. </template>
  493. <script>
  494. import {
  495. getEnginDetail,
  496. addEngin,
  497. editEngin,
  498. getEnginGoodsList,
  499. getWarehouseList,
  500. getDealerList,
  501. getEnginGoodsDetail
  502. } from '@/api/supply/apply'
  503. import { getDictList, getCategoryList } from '@/api/common'
  504. import { findElem } from '@/utils/util'
  505. import fileUpload from '@/components/Common/file-upload.vue'
  506. export default {
  507. components: {
  508. fileUpload
  509. },
  510. name: 'EnginForm',
  511. componentName: 'EnginForm',
  512. props: ['listItem'],
  513. filters: {
  514. orderTypeFilter(val) {
  515. const MAP = {
  516. HOME: '家用单',
  517. TRADE: '商用单',
  518. RETAIL: '零售单',
  519. RETAIL_POLICY: '销售政策单',
  520. PERMU_HOME: '置换家用单',
  521. PERMU_TRADE: '置换商用单',
  522. PERMU_RETAIL: '置换零售单',
  523. PERMU_RETAIL_POLICY: '置换销售政策单',
  524. REQUISITION_HOME: '调拨家用单',
  525. REQUISITION_TRADE: '调拨商用单',
  526. REQUISITION_RETAIL: '调拨零售单',
  527. REQUISITION_RETAIL_POLICY: '调拨销售政策单'
  528. }
  529. return MAP[val]
  530. }
  531. },
  532. data() {
  533. return {
  534. mainForm: {
  535. orderNum: '',
  536. orderDate: '',
  537. jxsNum: '',
  538. jxsName: '',
  539. loginNum: '',
  540. enginName: '',
  541. loginType: '',
  542. factoryNum: '',
  543. company: '',
  544. fileNo: '',
  545. contactMan: '',
  546. tel: '',
  547. phone: '',
  548. address: '',
  549. remark: '',
  550. createMan: '',
  551. createDate: '',
  552. examineRemark: '',
  553. refProjectName: '',
  554. refTradeCategory: ''
  555. },
  556. mainFormRules: {
  557. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  558. },
  559. dealerList: [],
  560. fileList: [],
  561. goodsList: [],
  562. warehouseList: [],
  563. isShowDialog: false,
  564. screenForm: {
  565. loginNum: '',
  566. enginName: '',
  567. model: '',
  568. date: [],
  569. warehouse: '',
  570. type: '',
  571. refProjectName: ''
  572. },
  573. currentPage: 1,
  574. listTotal: 0,
  575. typeList: [],
  576. stockList: [],
  577. categoryList: [],
  578. tableGoodsList: [],
  579. tableSelection: []
  580. }
  581. },
  582. computed: {
  583. sidebar() {
  584. return this.$store.state.app.sidebar
  585. },
  586. classObj() {
  587. return {
  588. hideSidebar: !this.sidebar.opened,
  589. openSidebar: this.sidebar.opened
  590. }
  591. },
  592. isDealer() {
  593. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  594. }
  595. },
  596. created() {
  597. this.getDictList()
  598. this.getWarehouseList()
  599. this.getDealerList()
  600. this.getCategoryList()
  601. if (this.listItem) {
  602. this.getDetail()
  603. } else {
  604. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  605. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  606. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  607. this.mainForm.createDate = this.getDate()
  608. }
  609. },
  610. methods: {
  611. // 返回列表
  612. goBack() {
  613. this.$emit('backListFormDetail')
  614. },
  615. getDate() {
  616. var date = new Date()
  617. var seperator1 = '-'
  618. var year = date.getFullYear()
  619. var month = date.getMonth() + 1
  620. var strDate = date.getDate()
  621. if (month >= 1 && month <= 9) {
  622. month = '0' + month
  623. }
  624. if (strDate >= 0 && strDate <= 9) {
  625. strDate = '0' + strDate
  626. }
  627. var currentdate = year + seperator1 + month + seperator1 + strDate
  628. return currentdate
  629. },
  630. // 获取详情
  631. getDetail() {
  632. getEnginDetail({ id: this.listItem.id }).then(res => {
  633. let data = res.data
  634. this.mainForm.orderNum = data.id
  635. this.mainForm.orderDate = data.orderTime.slice(0, 10)
  636. this.mainForm.jxsNum = data.customerNumber
  637. this.mainForm.jxsName = data.customerName
  638. this.mainForm.loginNum = data.refEnginRecordNo
  639. this.mainForm.loginType = data.enginOrderType
  640. this.mainForm.factoryNum = data.refFactoryNo
  641. this.mainForm.company = data.refUseUnit
  642. this.mainForm.saleType = data.saleTypeId
  643. this.mainForm.contactMan = data.refLinkman
  644. this.mainForm.tel = data.refTel
  645. this.mainForm.phone = data.refPhone
  646. this.mainForm.address = data.refInstallAddress
  647. this.mainForm.createMan = data.createBy
  648. this.mainForm.createDate = data.createTime
  649. this.mainForm.remark = data.remark
  650. this.mainForm.examineRemark = data.approvalRemark
  651. this.mainForm.fileNo = data.fileNo
  652. this.mainForm.refProjectName = data.refProjectName
  653. this.mainForm.enginName = data.refProjectCategory
  654. this.mainForm.refTradeCategory = data.refTradeCategory
  655. this.screenForm.warehouse = data.correspondId
  656. // this.screenForm.refProjectName = data.refProjectName
  657. data.salesOrderPictures.forEach(k => {
  658. k.name = k.fileName
  659. k.url = k.fileUrl
  660. })
  661. this.fileList = data.salesOrderPictures
  662. // data.orders.forEach(item => {
  663. // item.orderId = item.id;
  664. // })
  665. this.goodsList = data.orders
  666. })
  667. },
  668. // 获取仓库列表
  669. getWarehouseList() {
  670. getWarehouseList({
  671. pageNum: 1,
  672. pageSize: -1
  673. }).then(res => {
  674. this.warehouseList = res.data.records
  675. })
  676. },
  677. getDictList() {
  678. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  679. this.typeList = res.data
  680. })
  681. getDictList({ sysDictEnum: 'STOCK_ORDER' }).then(res => {
  682. this.stockList = res.data
  683. })
  684. },
  685. // 获取经销商列表
  686. getDealerList() {
  687. getDealerList({
  688. pageNum: 1,
  689. pageSize: -1,
  690. bindUser: false
  691. }).then(res => {
  692. this.dealerList = res.data.records
  693. })
  694. },
  695. // 获取存货类别列表
  696. getCategoryList() {
  697. getCategoryList({
  698. pageNum: 1,
  699. pageSize: -1
  700. }).then(res => {
  701. this.categoryList = res.data.records
  702. })
  703. },
  704. // 库存字段
  705. stockFilter(item, type) {
  706. let STOCK_ORDER_INVOICE = this.stockList.find(o => o.dictCode == 'STOCK_ORDER_INVOICE').dictValue
  707. if (type === 1) {
  708. return item.stockAdequate > STOCK_ORDER_INVOICE ? '充足' : item.stockAdequate
  709. }
  710. if (type === 2) {
  711. if (item.stockCorrespond <= 0) {
  712. return '无货'
  713. } else if (item.stockCorrespond >= 1 && item.stockCorrespond <= 30) {
  714. return item.stockCorrespond
  715. } else if (item.stockCorrespond >= 31 && item.stockCorrespond <= 1000) {
  716. return '有货'
  717. } else {
  718. return '充足'
  719. }
  720. // return item.stockCorrespond > STOCK_ORDER_INVOICE ? '充足' : item.stockCorrespond;
  721. }
  722. },
  723. // 获取商品列表
  724. getGoodsList() {
  725. getEnginGoodsList({
  726. pageNum: this.currentPage,
  727. pageSize: 10,
  728. refEnginRecordNo: this.screenForm.loginNum,
  729. refProjectName: this.screenForm.enginName,
  730. // refProjectCategory:this.screenForm.enginName,
  731. specification: this.screenForm.model,
  732. startTime: this.screenForm.date ? this.screenForm.date[0] : '',
  733. endTime: this.screenForm.date ? this.screenForm.date[1] : '',
  734. correspondId: this.screenForm.warehouse,
  735. categoryName: this.screenForm.type
  736. }).then(res => {
  737. let oldGoodsList = this.goodsList
  738. let newGoodsList = res.data.records
  739. for (let i = 0; i < oldGoodsList.length; i++) {
  740. let oldItem = oldGoodsList[i]
  741. for (let j = 0; j < newGoodsList.length; j++) {
  742. let newItem = newGoodsList[j]
  743. if (newItem.orderId === oldItem.orderId) {
  744. newGoodsList[j].selected = true
  745. break
  746. }
  747. }
  748. }
  749. newGoodsList.forEach(item => {
  750. item.invoiceNum = item.refundableQty
  751. })
  752. this.tableGoodsList = newGoodsList
  753. this.listTotal = res.data.total
  754. })
  755. },
  756. // 查询重复值并禁选
  757. checkboxSelect(row, rowIndex) {
  758. if (row.selected) {
  759. return false // 禁用
  760. } else {
  761. return true // 不禁用
  762. }
  763. },
  764. // 点击 选择商品
  765. openDialog() {
  766. this.isShowDialog = true
  767. if (this.screenForm.warehouse) {
  768. this.getGoodsList()
  769. }
  770. },
  771. // 提交筛选表单
  772. submitScreenForm() {
  773. if (!this.screenForm.warehouse) {
  774. return this.$errorMsg('请选择仓库')
  775. }
  776. this.currentPage = 1
  777. this.getGoodsList()
  778. },
  779. // 重置筛选表单
  780. resetScreenForm() {
  781. this.$refs.screenForm.resetFields()
  782. this.currentPage = 1
  783. this.tableGoodsList = []
  784. // this.getGoodsList();
  785. },
  786. // 更改列表当前页
  787. handleTableCurrentChange(val) {
  788. if (this.tableSelection.length > 0) {
  789. return this.$errorMsg('已选择产品不可切换')
  790. }
  791. this.currentPage = val
  792. this.getGoodsList()
  793. },
  794. // 关闭 弹窗
  795. closeDialog() {
  796. this.isShowDialog = false
  797. },
  798. // 列表选择
  799. tableSelectionChange(val) {
  800. this.tableSelection = val
  801. },
  802. // 检查是否一致
  803. isAllEqual(array) {
  804. if (array.length > 0) {
  805. return !array.some(function (item, index) {
  806. return item.enginOrderNo !== array[0].enginOrderNo
  807. })
  808. } else {
  809. return true
  810. }
  811. },
  812. // 确定 添加产品
  813. submitAddGoods() {
  814. let list = this.goodsList.concat(this.tableSelection)
  815. if (!this.isAllEqual(list)) {
  816. return this.$errorMsg('只能选择同一个工程编号的订单')
  817. }
  818. for (let i = 0; i < this.tableSelection.length; i++) {
  819. for (let j = i + 1; j < this.tableSelection.length; j++) {
  820. if (this.tableSelection[i].orderBase !== this.tableSelection[j].orderBase) {
  821. return this.$errorMsg('只能选择新单或旧单')
  822. }
  823. }
  824. if (this.tableSelection[i].invoiceNum === '') {
  825. this.$errorMsg('请输入申请数量')
  826. return
  827. }
  828. // if(this.tableSelection[i].invoiceNum > this.tableSelection[i].refundableQty) {
  829. // this.$errorMsg('申请数量不能大于未申请数量');
  830. // return;
  831. // }
  832. }
  833. this.isShowDialog = false
  834. this.tableGoodsList = []
  835. this.goodsList = this.goodsList.concat(this.tableSelection)
  836. this.getEnginGoodsDetail(this.tableSelection[0].enginOrderNo)
  837. },
  838. getEnginGoodsDetail(enginOrderNo) {
  839. getEnginGoodsDetail({ enginOrderNo }).then(res => {
  840. let data = res.data
  841. this.mainForm.loginNum = data.refEnginRecordNo
  842. this.mainForm.enginName = data.refProjectCategory
  843. this.mainForm.refProjectName = data.refProjectName
  844. this.mainForm.loginType = data.refPromiseStatus
  845. this.mainForm.factoryNum = data.refFactoryNo
  846. this.mainForm.company = data.refUseUnit
  847. this.mainForm.saleType = data.saleTypeId
  848. this.mainForm.contactMan = data.refLinkman
  849. this.mainForm.tel = data.refTel
  850. this.mainForm.phone = data.refPhone
  851. this.mainForm.address = data.refInstallAddress
  852. this.mainForm.remark = data.remark
  853. this.mainForm.fileNo = data.fileNo
  854. this.mainForm.refTradeCategory = data.refTradeCategory
  855. })
  856. },
  857. // 删除产品
  858. deleteItem(index) {
  859. this.goodsList.splice(index, 1)
  860. },
  861. // 保存
  862. clickSubmitForm(status) {
  863. this.$refs.mainForm.validate(valid => {
  864. if (valid) {
  865. if (this.goodsList.length < 1) {
  866. return this.$errorMsg('请添加引用')
  867. }
  868. for (let i = 0; i < this.goodsList.length; i++) {
  869. if (!Number(this.goodsList[i].invoiceNum)) {
  870. this.$errorMsg('请输入申请数量')
  871. return
  872. }
  873. // if(this.goodsList[i].invoiceNum > this.goodsList[i].refundableQty) {
  874. // this.$errorMsg('申请数量不能大于未申请数量');
  875. // return;
  876. // }
  877. }
  878. if (!this.screenForm.warehouse) {
  879. return this.$errorMsg('请选择仓库')
  880. }
  881. const salesOrderPictures = []
  882. if (this.fileList.length) {
  883. this.fileList.forEach(k => {
  884. salesOrderPictures.push({
  885. fileName: k.name,
  886. fileUrl: k.url,
  887. salesId: this.goodsList[0].id
  888. })
  889. })
  890. }
  891. let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name
  892. let params = {
  893. // orderTime: this.mainForm.orderDate + ' 00:00:00',
  894. refEnginRecordNo: this.mainForm.loginNum,
  895. refProjectName: this.mainForm.refProjectName,
  896. refTradeCategory: this.mainForm.refTradeCategory,
  897. refProjectCategory: this.mainForm.enginName,
  898. enginOrderType: this.mainForm.loginType,
  899. refFactoryNo: this.mainForm.factoryNum,
  900. refUseUnit: this.mainForm.company,
  901. refLinkman: this.mainForm.contactMan,
  902. refTel: this.mainForm.tel,
  903. refPhone: this.mainForm.phone,
  904. refInstallAddress: this.mainForm.address,
  905. remark: this.mainForm.remark,
  906. fileNo: this.mainForm.fileNo,
  907. fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
  908. fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
  909. correspondId: this.screenForm.warehouse,
  910. correspondName,
  911. orders: this.goodsList,
  912. examineStatus: status,
  913. salesOrderPictures
  914. }
  915. if (this.listItem) {
  916. params.id = this.listItem.id
  917. editEngin(params).then(res => {
  918. this.$successMsg('编辑成功')
  919. this.goBack()
  920. // this.$parent.getList()
  921. })
  922. } else {
  923. addEngin(params).then(res => {
  924. this.$successMsg('添加成功')
  925. this.goBack()
  926. // this.$parent.getList()
  927. })
  928. }
  929. }
  930. })
  931. }
  932. }
  933. }
  934. </script>
  935. <style scoped lang="scss">
  936. .detail-container {
  937. width: 100%;
  938. height: 100%;
  939. }
  940. .main-title {
  941. display: flex;
  942. justify-content: space-between;
  943. align-items: center;
  944. margin-top: 20px;
  945. height: 60px;
  946. border-bottom: 1px solid #dcdfe6;
  947. margin-bottom: 20px;
  948. .title {
  949. font-size: 16px;
  950. font-weight: 600;
  951. padding-left: 10px;
  952. }
  953. }
  954. </style>