engin_form.vue 30 KB

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