engin_form.vue 30 KB

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