commerce_form.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header :content="listItem ? '编辑' : '新增'" @back="goBack" />
  4. <div class="main-title">
  5. <div class="title">工程订单</div>
  6. </div>
  7. <el-form
  8. ref="mainForm"
  9. :model="mainForm"
  10. :rules="mainFormRules"
  11. label-width="110px"
  12. size="small"
  13. label-position="right"
  14. >
  15. <el-row :gutter="20">
  16. <el-col :xs="24" :sm="12" :lg="8">
  17. <el-form-item label="工程订单号" prop="orderNum">
  18. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  22. <el-form-item label="单据日期" prop="orderDate">
  23. <el-date-picker
  24. v-model="mainForm.orderDate"
  25. disabled
  26. type="date"
  27. value-format="yyyy-MM-dd"
  28. style="width: 100%"
  29. placeholder="系统自动生成"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8">
  34. <el-form-item label="业务员" prop="salesMan">
  35. <el-select
  36. v-model="mainForm.salesMan"
  37. placeholder="选择业务员"
  38. disabled
  39. size="small"
  40. filterable
  41. clearable
  42. style="width: 100%"
  43. >
  44. <el-option
  45. v-for="item in salesmanList"
  46. :key="item.adminUserId"
  47. :label="item.nickName"
  48. :value="item.adminUserId"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <!-- <el-col :xs="24" :sm="12" :lg="8">
  54. <el-form-item label="产品大类" prop="type">
  55. <el-select v-model="mainForm.type" placeholder="选择产品大类" style="width: 100%" disabled>
  56. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col> -->
  60. </el-row>
  61. <el-row :gutter="20">
  62. <el-col :xs="24" :sm="12" :lg="8">
  63. <el-form-item label="经销商编码" prop="jxsNum">
  64. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled />
  65. </el-form-item>
  66. </el-col>
  67. <el-col :xs="24" :sm="12" :lg="16">
  68. <el-form-item label="经销商名称" prop="jxsNum">
  69. <el-select
  70. v-model="mainForm.jxsNum"
  71. placeholder="选择经销商"
  72. size="small"
  73. filterable
  74. clearable
  75. style="width: 100%"
  76. :disabled="listItem != undefined || isDealer"
  77. @change="changeDealer"
  78. >
  79. <el-option v-for="item in dealerList" :key="item.number" :label="item.name" :value="item.number" />
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :xs="24" :sm="12" :lg="8">
  84. <el-form-item label="工程登录编号" prop="enginOrderNum">
  85. <div style="display: flex">
  86. <el-input v-model="mainForm.enginOrderNum" placeholder="请引用工程登录" disabled />
  87. <el-button style="margin-left: 10px" @click="openShareDetail">引用</el-button>
  88. </div>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :xs="24" :sm="12" :lg="8">
  92. <el-form-item label="项目名称" prop="projectName">
  93. <el-input v-model="mainForm.projectName" placeholder="请输入项目名称" disabled />
  94. </el-form-item>
  95. </el-col>
  96. <el-col :xs="24" :sm="12" :lg="8">
  97. <el-form-item label="行业类别" prop="loginType">
  98. <el-input v-model="mainForm.tradeCategory" placeholder="请输入行业类别" disabled />
  99. </el-form-item>
  100. </el-col>
  101. <el-col :xs="24" :sm="12" :lg="8">
  102. <el-form-item label="跨区厂编号" prop="factoryNo">
  103. <el-input v-model="mainForm.factoryNo" placeholder="请输入跨区厂编号" :disabled="isDealer" />
  104. </el-form-item>
  105. </el-col>
  106. <el-col :xs="24" :sm="12" :lg="8">
  107. <el-form-item label="使用单位" prop="useUnit">
  108. <el-input v-model="mainForm.useUnit" placeholder="请输入使用单位" disabled />
  109. </el-form-item>
  110. </el-col>
  111. <el-col :xs="24" :sm="12" :lg="8">
  112. <el-form-item label="工程编号" prop="projectNo">
  113. <el-input v-model="mainForm.projectNo" placeholder="请输入工程编号" disabled />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :xs="24" :sm="12" :lg="8">
  117. <el-form-item label="联系人" prop="linkman">
  118. <el-input v-model="mainForm.linkman" placeholder="请输入联系人" disabled />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :xs="24" :sm="12" :lg="8">
  122. <el-form-item label="固定电话" prop="tel">
  123. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" disabled />
  124. </el-form-item>
  125. </el-col>
  126. <el-col :xs="24" :sm="12" :lg="8">
  127. <el-form-item label="移动电话" prop="phone">
  128. <el-input v-model="mainForm.phone" placeholder="请输入移动电话" disabled />
  129. </el-form-item>
  130. </el-col>
  131. <el-col :xs="24" :sm="12" :lg="8">
  132. <el-form-item label="工程登录类型" prop="signType">
  133. <el-input v-model="mainForm.signType" placeholder="请输入工程登录类型" disabled />
  134. </el-form-item>
  135. </el-col>
  136. <el-col :xs="24" :sm="24" :lg="24">
  137. <el-form-item label="安装地址" prop="installAddress">
  138. <el-input v-model="mainForm.installAddress" placeholder="请输入安装地址" disabled />
  139. </el-form-item>
  140. </el-col>
  141. <el-col v-if="!isDealer" :xs="24" :sm="24" :lg="16">
  142. <el-form-item label="格力内部备注" prop="geLiInerNote">
  143. <el-input v-model="mainForm.geLiInerNote" placeholder="请输入格力内部备注" />
  144. </el-form-item>
  145. </el-col>
  146. <el-col v-if="!isDealer" :xs="24" :sm="12" :lg="8">
  147. <el-form-item label="权限分类" prop="powerCategory">
  148. <el-select
  149. v-model="mainForm.powerCategory"
  150. placeholder="选择权限分类"
  151. size="small"
  152. clearable
  153. style="width: 100%"
  154. >
  155. <el-option
  156. v-for="item in powerList"
  157. :key="item.dictCode"
  158. :label="item.dictValue"
  159. :value="item.dictCode"
  160. />
  161. </el-select>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :xs="24" :sm="24" :lg="24">
  165. <el-form-item label="格力回复" prop="geLiNote">
  166. <el-input
  167. v-model="mainForm.geLiNote"
  168. :placeholder="isDealer ? '' : '请输入格力回复'"
  169. :disabled="isDealer"
  170. />
  171. </el-form-item>
  172. </el-col>
  173. <el-col :xs="24" :sm="24" :lg="24">
  174. <el-form-item label="备注" prop="remark">
  175. <el-input v-model="mainForm.remark" placeholder="请输入备注" />
  176. </el-form-item>
  177. </el-col>
  178. <el-col :xs="24" :sm="12" :lg="8">
  179. <el-form-item label="制单人" prop="createMan">
  180. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled />
  181. </el-form-item>
  182. </el-col>
  183. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  184. <el-form-item label="制单日期" prop="createDate">
  185. <el-date-picker
  186. v-model="mainForm.createDate"
  187. disabled
  188. type="date"
  189. value-format="yyyy-MM-dd"
  190. style="width: 100%"
  191. placeholder="选择日期"
  192. />
  193. </el-form-item>
  194. </el-col>
  195. <el-col :xs="24" :sm="12" :lg="8">
  196. <el-form-item label="文件编号" prop="fileNo">
  197. <el-input v-model="mainForm.fileNo" placeholder="请输入文件编号" />
  198. </el-form-item>
  199. </el-col>
  200. <el-col v-if="mainForm.examineRemark" :xs="24" :sm="24" :lg="24">
  201. <el-form-item label="审批说明" prop="examineRemark">
  202. <el-input v-model="mainForm.examineRemark" placeholder="请输入审批说明" disabled />
  203. </el-form-item>
  204. </el-col>
  205. <!-- <el-col :xs="24" :sm="24" :lg="24">-->
  206. <!-- <el-form-item>-->
  207. <!-- <el-checkbox v-model="isPlanOrder" :disabled="listItem" true-label="true" false-label="false">计划单</el-checkbox>-->
  208. <!-- </el-form-item>-->
  209. <!-- </el-col>-->
  210. </el-row>
  211. </el-form>
  212. <div class="main-title">
  213. <div class="title">货品信息</div>
  214. <div>
  215. <el-select
  216. v-model="warehouseValue"
  217. placeholder="请选择发货仓库"
  218. size="small"
  219. style="margin-right: 10px"
  220. :disabled="!flag"
  221. @change="setStock"
  222. >
  223. <el-option v-for="(item, index) in warehouseList" :key="index" :label="item.name" :value="item.id" />
  224. </el-select>
  225. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  226. </div>
  227. </div>
  228. <div class="table" style="margin-top: 20px">
  229. <el-table
  230. :data="goodsList"
  231. element-loading-text="Loading"
  232. border
  233. fit
  234. highlight-current-row
  235. stripe
  236. max-height="400"
  237. @selection-change="handleSelectionChange"
  238. >
  239. <el-table-column align="center" type="selection" width="55" />
  240. <el-table-column align="center" label="序号" type="index" width="50" />
  241. <!-- <el-table-column align="center" label="引用记录" prop="useRefCount" min-width="160" show-overflow-tooltip></el-table-column>-->
  242. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip />
  243. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip />
  244. <el-table-column
  245. align="center"
  246. label="产品编码"
  247. prop="materialOldNumber"
  248. min-width="120"
  249. show-overflow-tooltip
  250. />
  251. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip />
  252. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  253. <template slot-scope="scope">
  254. <el-input v-if="listItem" v-model="scope.row.specification" size="small" />
  255. <div v-else>{{ scope.row.specification }}</div>
  256. </template>
  257. </el-table-column>
  258. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip />
  259. <el-table-column align="center" label="已订数量" prop="hasOrderQty" min-width="80" show-overflow-tooltip />
  260. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  261. <template slot-scope="scope">
  262. <el-input
  263. v-if="!isDealer"
  264. v-model="scope.row.price"
  265. size="small"
  266. type="number"
  267. @mousewheel.native.prevent
  268. />
  269. <div v-else>{{ scope.row.price }}</div>
  270. </template>
  271. </el-table-column>
  272. <el-table-column align="center" label="工程信息数量" prop="enginNum" min-width="120" show-overflow-tooltip />
  273. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  274. <template slot-scope="scope">
  275. <el-input v-model="scope.row.qty" size="small" />
  276. </template>
  277. </el-table-column>
  278. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  279. <template slot-scope="scope">
  280. <div>{{ status2Filter(scope.row) }}</div>
  281. </template>
  282. </el-table-column>
  283. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  284. <template slot-scope="scope">
  285. {{ scope.row.price * scope.row.qty }}
  286. </template>
  287. </el-table-column>
  288. <el-table-column align="center" label="返利钱包" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  289. <template slot-scope="scope">
  290. <el-select
  291. v-model="scope.row.customerWalletId2"
  292. placeholder="选择返利类型"
  293. size="small"
  294. clearable
  295. @change="changeFlWallet(scope.$index)"
  296. >
  297. <el-option
  298. v-for="item in scope.row.rebateWallets"
  299. :key="item.customerWalletId"
  300. :label="item.customerWalletName"
  301. :value="item.customerWalletId"
  302. />
  303. </el-select>
  304. </template>
  305. </el-table-column>
  306. <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
  307. <template slot-scope="scope">
  308. {{ (scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100 }}
  309. </template>
  310. </el-table-column>
  311. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  312. <template slot-scope="scope">
  313. {{ scope.row.qty * scope.row.discAmount }}
  314. </template>
  315. </el-table-column>
  316. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  317. <template slot-scope="scope">
  318. <el-select
  319. v-model="scope.row.customerWalletId"
  320. placeholder="选择现金钱包"
  321. size="small"
  322. clearable
  323. @change="changeXjWallet(scope.$index)"
  324. >
  325. <el-option
  326. v-for="item in scope.row.wallets"
  327. :key="item.customerWalletId"
  328. :label="item.customerWalletName"
  329. :value="item.customerWalletId"
  330. />
  331. </el-select>
  332. </template>
  333. </el-table-column>
  334. <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  335. <template slot-scope="scope">
  336. {{
  337. (scope.row.price * scope.row.qty * 100 -
  338. ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 -
  339. ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
  340. 100
  341. }}
  342. </template>
  343. </el-table-column>
  344. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  345. <template slot-scope="scope">
  346. <el-checkbox v-model="scope.row.isDirectTransfer" />
  347. </template>
  348. </el-table-column>
  349. <el-table-column align="center" label="直调数量" prop="directTransferQty" min-width="100" />
  350. <el-table-column align="center" label="已发货数量" prop="hasSendQty" min-width="100" show-overflow-tooltip />
  351. <el-table-column align="center" label="已退数量" prop="retiredQty" min-width="100" show-overflow-tooltip />
  352. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  353. <template slot-scope="scope">
  354. <el-input v-model="scope.row.remark" size="small" />
  355. </template>
  356. </el-table-column>
  357. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip />
  358. <el-table-column align="center" label="仓库" prop="correspondName" min-width="100" show-overflow-tooltip />
  359. <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  360. <template slot-scope="scope">
  361. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" disabled size="small" clearable>
  362. <el-option
  363. v-for="item in salesmanList"
  364. :key="item.adminUserId"
  365. :label="item.nickName"
  366. :value="item.adminUserId"
  367. />
  368. </el-select>
  369. </template>
  370. </el-table-column>
  371. <el-table-column align="center" label="操作" width="100" fixed="right">
  372. <template slot-scope="scope">
  373. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  374. </template>
  375. </el-table-column>
  376. </el-table>
  377. </div>
  378. <div class="page-footer">
  379. <div class="footer">
  380. <!-- <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button> -->
  381. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  382. <el-popconfirm title="确定关闭吗?" style="margin-left: 10px" @onConfirm="goBack">
  383. <el-button slot="reference">返回列表</el-button>
  384. </el-popconfirm>
  385. </div>
  386. </div>
  387. <!-- 工程登录列表 -->
  388. <el-dialog title="工程登录列表" :visible.sync="isShowDialog" width="70%" :close-on-click-modal="false">
  389. <el-form ref="screenForm" :model="screenForm" label-width="0" size="small" label-position="left">
  390. <el-row :gutter="20">
  391. <el-col :xs="24" :sm="12" :lg="6">
  392. <el-form-item prop="enginNum">
  393. <el-input v-model="screenForm.enginNum" placeholder="工程信息单" />
  394. </el-form-item>
  395. </el-col>
  396. <el-col :xs="24" :sm="12" :lg="6">
  397. <el-form-item prop="projectName">
  398. <el-input v-model="screenForm.projectName" placeholder="工程项目" />
  399. </el-form-item>
  400. </el-col>
  401. <el-col :xs="24" :sm="12" :lg="6">
  402. <el-form-item prop="useUnit">
  403. <el-input v-model="screenForm.useUnit" placeholder="使用单位" />
  404. </el-form-item>
  405. </el-col>
  406. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  407. <el-form-item label="">
  408. <el-button size="small" @click="resetScreenForm">清空</el-button>
  409. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  410. </el-form-item>
  411. </el-col>
  412. </el-row>
  413. </el-form>
  414. <div class="table" style="margin: 10px 0 20px">
  415. <el-table
  416. v-loading="dialogTable_listLoading"
  417. :data="dialogTable_dataList"
  418. element-loading-text="Loading"
  419. tooltip-effect="dark"
  420. style="width: 100%"
  421. max-height="270"
  422. >
  423. <el-table-column align="center" label="" width="100">
  424. <template slot-scope="scope">
  425. <el-button type="primary" size="small" @click="chooseItem(scope.row.enginInfoNo)">选择</el-button>
  426. </template>
  427. </el-table-column>
  428. <el-table-column align="center" prop="orderDate" label="工程登录日期" show-overflow-tooltip />
  429. <el-table-column align="center" prop="enginInfoNo" label="工程信息单" show-overflow-tooltip />
  430. <el-table-column align="center" prop="projectName" label="工程项目" show-overflow-tooltip />
  431. <el-table-column align="center" prop="useUnit" label="使用单位" show-overflow-tooltip />
  432. </el-table>
  433. </div>
  434. <div class="pagination clearfix">
  435. <div class="fr">
  436. <el-pagination
  437. :current-page="dialogTable_currentPage"
  438. :page-size="dialogTable_pageSize"
  439. background
  440. layout="prev, pager, next"
  441. :total="dialogTable_listTotal"
  442. @current-change="dialogTableCurrentChange"
  443. />
  444. </div>
  445. </div>
  446. <div slot="footer" class="dialog-footer">
  447. <el-button @click="isShowDialog = false">关 闭</el-button>
  448. </div>
  449. </el-dialog>
  450. </div>
  451. </template>
  452. <script>
  453. import {
  454. getOrderDetail,
  455. getComLoginList,
  456. getComLoginDetail,
  457. getWarehouseList,
  458. addCom,
  459. editCom,
  460. submitCom,
  461. checkStock,
  462. getWalletList
  463. } from '@/api/supply/engin'
  464. import { getDictList, getTypeList, getSalesmanList, getDealerList } from '@/api/common'
  465. import { findElem } from '@/utils/util'
  466. let that
  467. export default {
  468. name: 'CommerceForm',
  469. componentName: 'CommerceForm',
  470. filters: {
  471. status1Filter(val) {
  472. const STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue
  473. const STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue
  474. const STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue
  475. const STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue
  476. const STOCK_ORDER_ALL_NUM = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_ALL_NUM').dictValue
  477. if (val === '' || val === null || val === undefined) return '未检查'
  478. else if (val <= 0) return '无货'
  479. else if (val > STOCK_ORDER_START && val <= STOCK_ORDER_END) return val
  480. else if (val >= STOCK_ORDER_HAVE_START && val <= STOCK_ORDER_HAVE_END) return '有货'
  481. else if (val > STOCK_ORDER_ALL_NUM) return '充足'
  482. }
  483. },
  484. props: ['listItem'],
  485. data() {
  486. return {
  487. editId: '',
  488. mainForm: {
  489. orderNum: '',
  490. orderDate: '',
  491. // type: '',
  492. jxsNum: '',
  493. jxsName: '',
  494. jxsId: '',
  495. enginOrderNum: '',
  496. projectName: '',
  497. projectType: '',
  498. projectNote: '',
  499. machineType: '',
  500. useUnit: '',
  501. installAddress: '',
  502. projectNo: '',
  503. factoryNo: '',
  504. signType: '',
  505. tradeCategory: '',
  506. linkman: '',
  507. phone: '',
  508. tel: '',
  509. declareNo: '',
  510. powerCategory: '',
  511. geLiNote: '',
  512. geLiInerNote: '',
  513. remark: '',
  514. createMan: '',
  515. createDate: '',
  516. fileNo: '',
  517. salesMan: '',
  518. examineRemark: ''
  519. },
  520. mainFormRules: {
  521. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  522. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  523. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  524. enginOrderNum: [{ required: true, message: '请输入工程登录编号', trigger: 'blur' }],
  525. // projectName: [{ required: true, message: '请输入项目类别', trigger: 'blur' }],
  526. // tradeCategory: [{ required: true, message: '请输入行业类别', trigger: 'blur' }],
  527. useUnit: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  528. // linkman: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  529. // tel: [{ required: true, message: '请输入固定电话', trigger: 'blur' }],
  530. // phone: [{ required: true, message: '请输入移动电话', trigger: 'blur' }],
  531. installAddress: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  532. projectNo: [{ required: true, message: '请输入工程编号', trigger: 'blur' }]
  533. },
  534. // typeList: [],
  535. stockList: [],
  536. goodsList: [],
  537. powerList: [],
  538. multipleSelection: [],
  539. dealerList: [],
  540. isShowDialog: false, // 工程登录列表 - 弹窗
  541. screenForm: {
  542. enginNum: '',
  543. projectName: '',
  544. useUnit: ''
  545. },
  546. dialogTable_dataList: null, // 工程登录列表 - 列表数据
  547. dialogTable_listLoading: true, // 工程登录列表 - 列表加载loading
  548. dialogTable_currentPage: 1, // 工程登录列表 - 当前页码
  549. dialogTable_pageSize: 10, // 工程登录列表 - 每页数量
  550. dialogTable_listTotal: 0, // 工程登录列表 - 列表总数
  551. warehouseList: [],
  552. warehouseValue: '',
  553. flag: false,
  554. isFirst: false,
  555. salesmanList: [],
  556. isPlanOrder: 'true'
  557. }
  558. },
  559. computed: {
  560. isDealer() {
  561. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  562. },
  563. outSalesmanList() {
  564. const list = []
  565. if (this.goodsList && this.goodsList.length) {
  566. this.goodsList.forEach(item => {
  567. if (item.serviceId) {
  568. const hasItem = findElem(list, 'adminUserId', item.serviceId)
  569. if (hasItem < 0) {
  570. const obj = this.salesmanList.find(o => o.adminUserId == item.serviceId)
  571. if (obj) {
  572. list.push(obj)
  573. }
  574. }
  575. }
  576. })
  577. if (this.isFirst) {
  578. this.isFirst = false
  579. } else {
  580. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  581. }
  582. }
  583. return list
  584. }
  585. },
  586. watch: {
  587. goodsList: {
  588. handler(newValue, oldValue) {
  589. if (this.goodsList && this.goodsList.length) {
  590. this.flag = true
  591. if (this.isFirst) {
  592. this.isFirst = false
  593. } else {
  594. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  595. }
  596. return newValue
  597. } else {
  598. this.flag = false
  599. this.mainForm.salesMan = ''
  600. }
  601. },
  602. immediate: true,
  603. deep: true
  604. }
  605. },
  606. beforeCreate() {
  607. that = this
  608. },
  609. async created() {
  610. await this.getSalesmanList()
  611. this.getDictList()
  612. this.getWarehouseList()
  613. this.getDealerList()
  614. if (this.listItem) {
  615. this.isFirst = true
  616. this.editId = this.listItem.parentId
  617. this.getDetail()
  618. } else {
  619. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  620. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  621. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  622. this.mainForm.createDate = this.getDate()
  623. }
  624. },
  625. methods: {
  626. // 返回列表
  627. goBack() {
  628. this.$emit('backListFormDetail')
  629. },
  630. setStock(id) {
  631. if (this.goodsList.length) {
  632. const item = this.warehouseList.find(e => e.id === id)
  633. this.goodsList.forEach(k => {
  634. this.$set(k, 'correspondName', item.name)
  635. this.$set(k, 'correspondId', item.id)
  636. })
  637. }
  638. },
  639. getDate() {
  640. var date = new Date()
  641. var seperator1 = '-'
  642. var year = date.getFullYear()
  643. var month = date.getMonth() + 1
  644. var strDate = date.getDate()
  645. if (month >= 1 && month <= 9) {
  646. month = '0' + month
  647. }
  648. if (strDate >= 0 && strDate <= 9) {
  649. strDate = '0' + strDate
  650. }
  651. var currentdate = year + seperator1 + month + seperator1 + strDate
  652. return currentdate
  653. },
  654. // 获取产品大类列表
  655. getDictList() {
  656. getDictList({ sysDictEnum: 'STOCK_ORDER' }).then(res => {
  657. this.stockList = res.data
  658. })
  659. getDictList({ sysDictEnum: 'POWER_CATEGORY' }).then(res => {
  660. this.powerList = res.data
  661. })
  662. },
  663. // 获取仓库列表
  664. getWarehouseList() {
  665. getWarehouseList({
  666. pageNum: 1,
  667. pageSize: -1
  668. }).then(res => {
  669. this.warehouseList = res.data.records
  670. })
  671. },
  672. async getSalesmanList() {
  673. const res = await getSalesmanList({
  674. pageNum: 1,
  675. pageSize: -1,
  676. isCustomer: 0,
  677. status: true
  678. })
  679. this.salesmanList = res.data.records
  680. },
  681. // 获取经销商列表
  682. getDealerList() {
  683. getDealerList({
  684. pageNum: 1,
  685. pageSize: -1
  686. // bindUser: false
  687. }).then(res => {
  688. this.dealerList = res.data.records
  689. })
  690. },
  691. changeDealer() {
  692. if (this.mainForm.jxsNum) {
  693. const jxsItem = this.dealerList.find(o => o.number == this.mainForm.jxsNum)
  694. this.mainForm.jxsName = jxsItem.name
  695. this.mainForm.jxsId = jxsItem.id
  696. } else {
  697. this.mainForm.jxsName = ''
  698. this.mainForm.jxsId = ''
  699. }
  700. },
  701. // 获取详情
  702. getDetail() {
  703. getOrderDetail({ id: this.editId }).then(res => {
  704. const data = res.data
  705. this.mainForm.orderNum = data.enginOrderId
  706. this.mainForm.orderDate = data.orderDate
  707. // this.mainForm.type = data.mainId;
  708. this.mainForm.jxsNum = data.customerNumber
  709. this.mainForm.jxsName = data.customerName
  710. this.mainForm.enginOrderNum = data.refEnginRecordNo
  711. this.mainForm.projectName = data.refProjectName
  712. this.mainForm.projectType = data.refProjectType
  713. this.mainForm.projectNote = data.refProjectNote
  714. this.mainForm.machineType = data.refMachineType
  715. this.mainForm.useUnit = data.refUseUnit
  716. this.mainForm.installAddress = data.refInstallAddress
  717. this.mainForm.projectNo = data.refProjectNo
  718. this.mainForm.factoryNo = data.refFactoryNo
  719. this.mainForm.signType = data.refPromiseStatus
  720. this.mainForm.tradeCategory = data.refTradeCategory
  721. this.mainForm.linkman = data.refLinkman
  722. this.mainForm.phone = data.refPhone
  723. this.mainForm.tel = data.refTel
  724. this.mainForm.geLiInerNote = data.geLiInerNote
  725. this.mainForm.geLiNote = data.geLiNote
  726. this.mainForm.remark = data.remark
  727. this.mainForm.createMan = data.createName
  728. this.mainForm.createDate = data.createTime
  729. this.mainForm.fileNo = data.fileNo
  730. this.mainForm.salesMan = data.serviceId
  731. this.mainForm.examineRemark = data.examineNote
  732. this.mainForm.powerCategory = data.refPowerCategory
  733. if (data.isPlanOrder !== '' || data.isPlanOrder !== null) {
  734. this.isPlanOrder = String(data.isPlanOrder)
  735. }
  736. data.items.forEach(item => {
  737. item.status1 = ''
  738. item.status2 = ''
  739. item.rebateWallets = item.customerWalletList.filter(item => {
  740. return item.type === 'REBATE'
  741. })
  742. item.wallets = item.customerWalletList.filter(item => {
  743. return item.type === 'COMMONLY'
  744. })
  745. })
  746. this.goodsList = data.items
  747. })
  748. },
  749. // 工程登录列表 - 获取列表
  750. getComLoginList() {
  751. getComLoginList({
  752. pageNum: this.dialogTable_currentPage,
  753. pageSize: this.dialogTable_pageSize,
  754. enginInfoNo: this.screenForm.enginNum,
  755. projectName: this.screenForm.projectName,
  756. useUnit: this.screenForm.useUnit,
  757. examineStatus: 'OK',
  758. customerKeyWord: this.listItem ? this.listItem.customerNumber : this.mainForm.jxsNum
  759. }).then(res => {
  760. this.dialogTable_dataList = res.data.records
  761. this.dialogTable_listTotal = res.data.total
  762. this.dialogTable_listLoading = false
  763. })
  764. },
  765. // 工程登录列表 - 打开弹窗
  766. openShareDetail() {
  767. if (!this.mainForm.jxsNum) {
  768. this.$errorMsg('请先选择经销商')
  769. return
  770. }
  771. this.isFirst = true
  772. this.isShowDialog = true
  773. this.dialogTable_currentPage = 1
  774. this.screenForm.correspondName = ''
  775. this.screenForm.correspondId = ''
  776. this.warehouseValue = ''
  777. this.getComLoginList()
  778. },
  779. // 工程登录列表 - 更改列表当前页
  780. dialogTableCurrentChange(val) {
  781. this.dialogTable_currentPage = val
  782. this.getComLoginList()
  783. },
  784. // 提交筛选表单
  785. submitScreenForm() {
  786. this.dialogTable_currentPage = 1
  787. this.getComLoginList()
  788. },
  789. // 重置筛选表单
  790. resetScreenForm() {
  791. this.$refs.screenForm.resetFields()
  792. this.dialogTable_currentPage = 1
  793. this.getComLoginList()
  794. },
  795. // 选择工程登录
  796. chooseItem(id) {
  797. getComLoginDetail({
  798. recordNo: id,
  799. enginOrderId: this.mainForm.orderNum,
  800. customerId: this.mainForm.jxsId
  801. }).then(res => {
  802. this.isShowDialog = false
  803. const data = res.data
  804. this.mainForm.enginOrderNum = data.enginInfoNo
  805. this.mainForm.projectName = data.projectName
  806. this.mainForm.projectType = data.projectType
  807. this.mainForm.projectNote = data.projectNote
  808. this.mainForm.projectNo = data.projectNo
  809. this.mainForm.machineType = data.machineType
  810. this.mainForm.useUnit = data.useUnit
  811. this.mainForm.tradeCategory = data.tradeCategory
  812. this.mainForm.signType = data.enginSignType
  813. this.mainForm.factoryNo = data.enginFactoryNo
  814. this.mainForm.linkman = data.linkman
  815. this.mainForm.tel = data.tel
  816. this.mainForm.phone = data.phone
  817. this.mainForm.installAddress = data.installAddress
  818. this.mainForm.salesMan = data.serviceId
  819. this.mainForm.powerCategory = data.powerCategory
  820. this.mainForm.remark = data.remark
  821. this.mainForm.geLiInerNote = data.geLiInerNote
  822. this.mainForm.geLiNote = data.geLiNote
  823. this.mainForm.fileNo = data.fileNo
  824. if (!this.isDealer) {
  825. this.mainForm.jxsNum = data.customerNumber
  826. this.mainForm.jxsName = data.customerName
  827. }
  828. this.goodsList = data.items.map(item => {
  829. return {
  830. useRefCount: item.useRefCount,
  831. saleTypeId: item.saleTypeId,
  832. saleTypeCode: item.saleTypeCode,
  833. saleTypeName: item.saleTypeName,
  834. materialId: item.materialId,
  835. materialNumber: item.materialNumber,
  836. materialOldNumber: item.materialOldNumber,
  837. materialName: item.materialName,
  838. specification: item.specification,
  839. enginNum: item.qty,
  840. enginPrice: item.price,
  841. enginTotality: item.totalAmount,
  842. historyHasDeliverQty: item.hasDeliverQty,
  843. unit: item.unit,
  844. price: item.price,
  845. qty: item.qty - item.hasOrderQty,
  846. customerWalletId2: '',
  847. rebateRate: '',
  848. discAmount: '',
  849. customerWalletId: '',
  850. isDirectTransfer: false,
  851. directTransferQty: '',
  852. hasSendQty: '',
  853. hasOrderQty: item.hasOrderQty,
  854. remark: item.remark,
  855. tax: item.taxRate,
  856. status1: '',
  857. status2: '',
  858. serviceId: '',
  859. serviceName: '',
  860. rebateWallets: item.customerWalletList.filter(item => {
  861. return item.type === 'REBATE'
  862. }),
  863. wallets: item.customerWalletList.filter(item => {
  864. return item.type === 'COMMONLY'
  865. })
  866. }
  867. })
  868. this.goodsList.forEach(item => {
  869. item.customerWalletId = item.wallets && item.wallets.length ? item.wallets[0].customerWalletId : ''
  870. item.serviceId = item.wallets && item.wallets.length ? item.wallets[0].serviceId : ''
  871. item.serviceName = item.wallets && item.wallets.length ? item.wallets[0].serviceName : ''
  872. })
  873. })
  874. },
  875. // 删除产品
  876. deleteItem(index) {
  877. this.goodsList.splice(index, 1)
  878. },
  879. // 修改返利钱包
  880. changeFlWallet(index) {
  881. if (this.goodsList[index].customerWalletId2) {
  882. const obj = this.goodsList[index].rebateWallets.find(
  883. o => o.customerWalletId == this.goodsList[index].customerWalletId2
  884. )
  885. this.goodsList[index].rebateRate = obj.rebateRate
  886. this.goodsList[index].customerWalletName2 = obj.customerWalletName
  887. } else {
  888. this.goodsList[index].rebateRate = ''
  889. this.goodsList[index].customerWalletName2 = ''
  890. }
  891. },
  892. // 修改现金钱包
  893. changeXjWallet(index) {
  894. if (this.goodsList[index].customerWalletId) {
  895. const obj = this.goodsList[index].wallets.find(
  896. o => o.customerWalletId == this.goodsList[index].customerWalletId
  897. )
  898. this.goodsList[index].customerWalletName = obj.customerWalletName
  899. this.goodsList[index].serviceId = obj.serviceId
  900. this.goodsList[index].serviceName = obj.serviceName
  901. } else {
  902. this.goodsList[index].customerWalletName = ''
  903. this.goodsList[index].serviceId = ''
  904. this.goodsList[index].serviceName = ''
  905. }
  906. },
  907. // 检查库存
  908. checkStock() {
  909. if (!this.warehouseValue) {
  910. return this.$errorMsg('请选择仓库')
  911. }
  912. if (!this.goodsList) {
  913. return this.$errorMsg('请添加货品')
  914. }
  915. const ids = []
  916. this.goodsList.forEach(item => {
  917. ids.push(item.materialId)
  918. })
  919. checkStock({
  920. correspondId: this.warehouseValue,
  921. materialId: ids.join(',')
  922. }).then(res => {
  923. if (res.data) {
  924. this.goodsList.forEach((item, index) => {
  925. item.status1 = res.data[index].allStockNum
  926. item.status2 = res.data[index].stockNum
  927. })
  928. }
  929. })
  930. },
  931. status2Filter(item) {
  932. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查'
  933. else if (item.status2 <= 0) return '无货'
  934. if (item.status2 <= 0) {
  935. return '无货'
  936. } else if (item.status2 >= 1 && item.status2 <= 30) {
  937. return item.status2
  938. } else if (item.status2 >= 31 && item.status2 <= 1000) {
  939. return '有货'
  940. } else {
  941. return '充足'
  942. }
  943. },
  944. handleSelectionChange(val) {
  945. this.multipleSelection = val
  946. },
  947. // 保存 / 提交审核
  948. clickSubmitForm(type) {
  949. this.$refs.mainForm.validate(valid => {
  950. if (valid) {
  951. if (this.goodsList.length < 1) {
  952. return this.$errorMsg('请添加产品')
  953. }
  954. if (this.multipleSelection.length < 1) {
  955. return this.$errorMsg('请选择产品')
  956. }
  957. for (let i = 0; i < this.multipleSelection.length; i++) {
  958. if (!this.multipleSelection[i].customerWalletId) {
  959. this.$errorMsg('请选择现金钱包')
  960. return
  961. }
  962. if (!this.multipleSelection[i].qty) {
  963. this.$errorMsg('请输入数量')
  964. return
  965. }
  966. if (this.multipleSelection[i].qty > this.multipleSelection[i].enginNum) {
  967. this.$errorMsg('数量不能大于工程信息数量')
  968. return
  969. }
  970. if (!this.multipleSelection[i].correspondId) {
  971. this.$errorMsg('请选择仓库')
  972. return
  973. }
  974. }
  975. const goodsList = JSON.parse(JSON.stringify(this.multipleSelection))
  976. goodsList.forEach(item => {
  977. delete item.rebateWallets
  978. delete item.wallets
  979. })
  980. const saleManItem = this.mainForm.salesMan
  981. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  982. : ''
  983. const params = {
  984. enginOrderId: this.mainForm.orderNum,
  985. // orderDate: this.mainForm.orderDate,
  986. // mainId: this.mainForm.type || '',
  987. refEnginRecordNo: this.mainForm.enginOrderNum || '',
  988. refProjectName: this.mainForm.projectName || '',
  989. refProjectType: this.mainForm.projectType || '',
  990. refProjectNote: this.mainForm.projectNote || '',
  991. refUseUnit: this.mainForm.useUnit || '',
  992. refInstallAddress: this.mainForm.installAddress || '',
  993. refProjectNo: this.mainForm.projectNo || '',
  994. refFactoryNo: this.mainForm.factoryNo || '',
  995. refPromiseStatus: this.mainForm.signType || '',
  996. refTradeCategory: this.mainForm.tradeCategory || '',
  997. refLinkman: this.mainForm.linkman || '',
  998. refPhone: this.mainForm.phone || '',
  999. refTel: this.mainForm.tel || '',
  1000. refPowerCategory: this.mainForm.powerCategory,
  1001. refMachineType: this.mainForm.machineType,
  1002. geLiInerNote: this.mainForm.geLiInerNote || '',
  1003. geLiNote: this.mainForm.geLiNote || '',
  1004. remark: this.mainForm.remark || '',
  1005. fileNo: this.mainForm.fileNo || '',
  1006. serviceId: this.mainForm.salesMan,
  1007. correspondId: goodsList[0].correspondId,
  1008. correspondName: goodsList[0].correspondName,
  1009. serviceName: saleManItem ? saleManItem.nickName : goodsList[0].serviceName,
  1010. isPlanOrder: this.isPlanOrder,
  1011. items: goodsList
  1012. }
  1013. if (type === 1) {
  1014. if (this.listItem) {
  1015. editCom(params).then(res => {
  1016. this.$successMsg('编辑成功')
  1017. this.goBack()
  1018. this.$parent.getList()
  1019. })
  1020. } else {
  1021. params.customerNumber = this.mainForm.jxsNum
  1022. params.customerName = this.mainForm.jxsName
  1023. params.customerId = this.mainForm.jxsId
  1024. addCom(params).then(res => {
  1025. this.$successMsg('新增成功')
  1026. this.goBack()
  1027. this.$parent.getList()
  1028. })
  1029. }
  1030. } else if (type === 2) {
  1031. params.customerNumber = this.mainForm.jxsNum
  1032. params.customerName = this.mainForm.jxsName
  1033. params.customerId = this.mainForm.jxsId
  1034. submitCom(params).then(res => {
  1035. this.$successMsg('提交审核成功')
  1036. this.goBack()
  1037. this.$parent.getList()
  1038. })
  1039. }
  1040. }
  1041. })
  1042. }
  1043. }
  1044. }
  1045. </script>
  1046. <style scoped lang="scss">
  1047. .detail-container {
  1048. width: 100%;
  1049. height: 100%;
  1050. }
  1051. .main-title {
  1052. display: flex;
  1053. justify-content: space-between;
  1054. align-items: center;
  1055. margin-top: 20px;
  1056. height: 60px;
  1057. border-bottom: 1px solid #dcdfe6;
  1058. margin-bottom: 20px;
  1059. .title {
  1060. font-size: 16px;
  1061. font-weight: 600;
  1062. padding-left: 10px;
  1063. }
  1064. }
  1065. ::v-deep input::-webkit-outer-spin-button,
  1066. ::v-deep input::-webkit-inner-spin-button {
  1067. -webkit-appearance: none;
  1068. }
  1069. ::v-deep input[type='number'] {
  1070. -moz-appearance: textfield;
  1071. }
  1072. </style>