commerce_form.vue 42 KB

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