engin_form.vue 31 KB

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