engin_form.vue 27 KB

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