commerce_form.vue 43 KB

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