engin_form.vue 28 KB

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