home_form.vue 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">工程订单</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="110px" size="small" label-position="right">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="工程订单" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. disabled
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%;"
  22. placeholder="系统自动生成">
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="8">
  27. <el-form-item label="销售类型" prop="saleType">
  28. <el-select v-model="mainForm.saleType" placeholder="选择销售类型" style="width: 100%" clearable @change="changeSaleType">
  29. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8">
  34. <el-form-item label="经销商编码" prop="jxsNum">
  35. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :xs="24" :sm="12" :lg="16">
  39. <el-form-item label="经销商名称" prop="jxsName">
  40. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :xs="24" :sm="12" :lg="8">
  44. <el-form-item label="工程登录编号" prop="loginNum">
  45. <div style="display: flex;">
  46. <el-input v-model="mainForm.loginNum" placeholder="请引用工程登录" disabled></el-input>
  47. <el-button style="margin-left: 10px;" @click="openShareDetail">引用</el-button>
  48. </div>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :xs="24" :sm="12" :lg="8">
  52. <el-form-item label="项目类别" prop="enginName">
  53. <el-input v-model="mainForm.enginName" placeholder="请输入项目类别" :disabled="isDealer"></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :xs="24" :sm="12" :lg="8">
  57. <el-form-item label="行业类别" prop="loginType">
  58. <el-input v-model="mainForm.loginType" placeholder="请输入行业类别"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :xs="24" :sm="12" :lg="8">
  62. <el-form-item label="跨区厂编号" prop="factoryNum">
  63. <el-input v-model="mainForm.factoryNum" placeholder="请输入跨区厂编号" :disabled="isDealer"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :xs="24" :sm="12" :lg="8">
  67. <el-form-item label="使用单位" prop="company">
  68. <el-input v-model="mainForm.company" placeholder="请输入使用单位" :disabled="isDealer"></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :xs="24" :sm="12" :lg="8">
  72. <el-form-item label="业务员" prop="salesMan">
  73. <el-select v-model="mainForm.salesMan" placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
  74. <el-option
  75. v-for="item in salesmanList"
  76. :key="item.adminUserId"
  77. :label="item.nickName"
  78. :value="item.adminUserId">
  79. </el-option>
  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="refCount">
  85. <el-input v-model="mainForm.refCount" placeholder="请输入引用记录" :disabled="isDealer"></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :xs="24" :sm="12" :lg="8">
  89. <el-form-item label="第几次申报" prop="declareNo">
  90. <el-input v-model="mainForm.declareNo" placeholder="请输入第几次申报" :disabled="isDealer"></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :xs="24" :sm="12" :lg="8">
  94. <el-form-item label="项目类型" prop="projectType">
  95. <el-input v-model="mainForm.projectType" placeholder="请输入项目类型" :disabled="isDealer"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :xs="24" :sm="12" :lg="8">
  99. <el-form-item label="区域" prop="regionWork">
  100. <el-input v-model="mainForm.regionWork" placeholder="请输入区域" :disabled="isDealer"></el-input>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :xs="24" :sm="12" :lg="8">
  104. <el-form-item label="文件编号" prop="fileNum">
  105. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号" :disabled="isDealer"></el-input>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :xs="24" :sm="12" :lg="8">
  109. <el-form-item label="购买单位" prop="refBuyUnitName">
  110. <el-input v-model="mainForm.refBuyUnitName" placeholder="请输入购买单位" :disabled="isDealer"></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :xs="24" :sm="12" :lg="8">
  114. <el-form-item label="联系人" prop="contactMan">
  115. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人"></el-input>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :xs="24" :sm="12" :lg="8">
  119. <el-form-item label="固定电话" prop="tel">
  120. <el-input v-model="mainForm.tel" placeholder="请输入固定电话"></el-input>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :xs="24" :sm="12" :lg="8">
  124. <el-form-item label="移动电话" prop="phone">
  125. <el-input v-model="mainForm.phone" placeholder="请输入移动电话"></el-input>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :xs="24" :sm="16" :lg="16">
  129. <el-form-item label="安装地址" prop="address">
  130. <el-input v-model="mainForm.address" placeholder="请输入安装地址" :disabled="isDealer"></el-input>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :xs="24" :sm="8" :lg="8">
  134. <el-form-item label="保证函" prop="refPromiseProvide">
  135. <el-select v-model="mainForm.refPromiseProvide" placeholder="选择保证函状态" size="small" clearable style="width: 100%">
  136. <el-option label="未保证" value="未保证"></el-option>
  137. <el-option label="已保证" value="已保证"></el-option>
  138. </el-select>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :xs="24" :sm="24" :lg="24">
  142. <el-form-item label="项目说明" prop="projectRemark">
  143. <el-input v-model="mainForm.projectRemark" placeholder="请输入项目说明" :disabled="isDealer"></el-input>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :xs="24" :sm="24" :lg="24" v-if="!isDealer">
  147. <el-form-item label="格力内部备注" prop="greeRemark">
  148. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注"></el-input>
  149. </el-form-item>
  150. </el-col>
  151. <!-- <el-col :xs="24" :sm="24" :lg="24">
  152. <el-form-item label="格力回复" prop="greeReply">
  153. <el-input v-model="mainForm.greeReply" placeholder="请输入格力回复"></el-input>
  154. </el-form-item>
  155. </el-col> -->
  156. <el-col :xs="24" :sm="24" :lg="24">
  157. <el-form-item label="备注" prop="remark">
  158. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  159. </el-form-item>
  160. </el-col>
  161. <el-col :xs="24" :sm="12" :lg="8">
  162. <el-form-item label="制单人" prop="createMan">
  163. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  167. <el-form-item label="制单日期" prop="createDate">
  168. <el-date-picker
  169. v-model="mainForm.createDate"
  170. disabled
  171. type="date"
  172. :default-value="getDate()"
  173. value-format="yyyy-MM-dd"
  174. style="width: 100%;"
  175. placeholder="选择日期">
  176. </el-date-picker>
  177. </el-form-item>
  178. </el-col>
  179. <el-col :xs="24" :sm="24" :lg="24" v-if="mainForm.examineRemark">
  180. <el-form-item label="审批说明" prop="examineRemark">
  181. <el-input v-model="mainForm.examineRemark" placeholder="请输入审批说明" disabled></el-input>
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. </el-form>
  186. <div class="main-title">
  187. <div class="title">货品信息</div>
  188. <div>
  189. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  190. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  191. </el-select>
  192. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  193. <el-divider direction="vertical"></el-divider>
  194. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  195. </div>
  196. </div>
  197. <div class="table" style="margin-top: 20px">
  198. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  199. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  200. <!-- <el-table-column align="center" label="引用记录" prop="useRefCount" min-width="160" show-overflow-tooltip></el-table-column> -->
  201. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
  202. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  203. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  204. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  205. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  206. <template slot-scope="scope">
  207. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  208. <div v-else>{{scope.row.specification}}</div>
  209. </template>
  210. </el-table-column>
  211. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  212. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  213. <template slot-scope="scope">
  214. <el-input v-model="scope.row.price" size="small" type="number"></el-input>
  215. </template>
  216. </el-table-column>
  217. <el-table-column align="center" label="工程登录数量" prop="enginNum" min-width="120" show-overflow-tooltip></el-table-column>
  218. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  219. <template slot-scope="scope">
  220. <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
  221. </template>
  222. </el-table-column>
  223. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  224. <template slot-scope="scope">
  225. {{scope.row.price * scope.row.qty}}
  226. </template>
  227. </el-table-column>
  228. <el-table-column align="center" label="返利类型" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  229. <template slot-scope="scope">
  230. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利类型" size="small" clearable @change="changeFlWallet(scope.$index)">
  231. <el-option
  232. v-for="item in scope.row.rebateWallets"
  233. :key="item.customerWalletId"
  234. :label="item.customerWalletName"
  235. :value="item.customerWalletId">
  236. </el-option>
  237. </el-select>
  238. </template>
  239. </el-table-column>
  240. <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
  241. <template slot-scope="scope">
  242. {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
  243. </template>
  244. </el-table-column>
  245. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  246. <template slot-scope="scope">
  247. {{scope.row.qty * scope.row.discAmount}}
  248. </template>
  249. </el-table-column>
  250. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  251. <template slot-scope="scope">
  252. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable @change="changeXjWallet(scope.$index)">
  253. <el-option
  254. v-for="item in scope.row.wallets"
  255. :key="item.customerWalletId"
  256. :label="item.customerWalletName"
  257. :value="item.customerWalletId">
  258. </el-option>
  259. </el-select>
  260. </template>
  261. </el-table-column>
  262. <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  263. <template slot-scope="scope">
  264. {{((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100}}
  265. </template>
  266. </el-table-column>
  267. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  268. <template slot-scope="scope">
  269. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  270. </template>
  271. </el-table-column>
  272. <el-table-column align="center" label="直调数量" prop="directTransferQty" min-width="100"></el-table-column>
  273. <el-table-column align="center" label="已发货数量" prop="hasSendQty" min-width="100" show-overflow-tooltip></el-table-column>
  274. <el-table-column align="center" label="已退数量" prop="retiredQty" min-width="100" show-overflow-tooltip></el-table-column>
  275. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  276. <template slot-scope="scope">
  277. <el-input v-model="scope.row.remark" size="small"></el-input>
  278. </template>
  279. </el-table-column>
  280. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  281. <!-- <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip>
  282. <template slot-scope="scope">
  283. <div>{{ scope.row.status1 | status1Filter }}</div>
  284. </template>
  285. </el-table-column> -->
  286. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  287. <template slot-scope="scope">
  288. <div>{{ status2Filter(scope.row) }}</div>
  289. </template>
  290. </el-table-column>
  291. <!-- <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  292. <template slot-scope="scope">
  293. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" size="small" clearable disabled>
  294. <el-option
  295. v-for="item in salesmanList"
  296. :key="item.adminUserId"
  297. :label="item.nickName"
  298. :value="item.adminUserId">
  299. </el-option>
  300. </el-select>
  301. </template>
  302. </el-table-column> -->
  303. <el-table-column align="center" label="操作" width="100" fixed="right">
  304. <template slot-scope="scope">
  305. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  306. </template>
  307. </el-table-column>
  308. </el-table>
  309. </div>
  310. <div class="page-footer">
  311. <div class="footer">
  312. <el-button type="primary" @click="clickSubmitForm(1)" :loading="formLoading">保 存</el-button>
  313. <el-button type="primary" @click="clickSubmitForm(2)" :loading="formLoading">提交审核</el-button>
  314. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  315. <el-button slot="reference">关 闭</el-button>
  316. </el-popconfirm>
  317. </div>
  318. </div>
  319. <!-- 工程登录列表 -->
  320. <el-dialog title="工程登录列表" :visible.sync="isShowDialog" width="70%" :close-on-click-modal="false">
  321. <el-form ref="screenForm" :model="screenForm" label-width="0" size="small" label-position="left">
  322. <el-row :gutter="20">
  323. <el-col :xs="24" :sm="12" :lg="6">
  324. <el-form-item prop="loginNum">
  325. <el-input v-model="screenForm.loginNum" placeholder="工程登录编号"></el-input>
  326. </el-form-item>
  327. </el-col>
  328. <el-col :xs="24" :sm="12" :lg="6">
  329. <el-form-item prop="enginName">
  330. <el-input v-model="screenForm.enginName" placeholder="工程类别"></el-input>
  331. </el-form-item>
  332. </el-col>
  333. <el-col :xs="24" :sm="12" :lg="6">
  334. <el-form-item prop="company">
  335. <el-input v-model="screenForm.company" placeholder="使用单位"></el-input>
  336. </el-form-item>
  337. </el-col>
  338. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  339. <el-form-item label="">
  340. <el-button size="small" @click="resetScreenForm">清空</el-button>
  341. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  342. </el-form-item>
  343. </el-col>
  344. </el-row>
  345. </el-form>
  346. <div class="table" style="margin: 10px 0 20px;">
  347. <el-table
  348. v-loading="dialogTable_listLoading"
  349. :data="dialogTable_dataList"
  350. element-loading-text="Loading"
  351. tooltip-effect="dark"
  352. style="width: 100%"
  353. max-height="270">
  354. <el-table-column align="center" label="" width="100">
  355. <template slot-scope="scope">
  356. <el-button type="primary" size="small" @click="chooseItem(scope.row.recordNo, scope.row.userid)">选择</el-button>
  357. </template>
  358. </el-table-column>
  359. <el-table-column align="center" prop="checkTime" label="工程登录日期" show-overflow-tooltip></el-table-column>
  360. <el-table-column align="center" prop="recordNo" label="工程登录编号" show-overflow-tooltip></el-table-column>
  361. <el-table-column align="center" prop="projectName" label="项目类别" show-overflow-tooltip></el-table-column>
  362. <el-table-column align="center" prop="useUnit" label="使用单位" show-overflow-tooltip></el-table-column>
  363. <el-table-column align="center" prop="organizationName" label="经销商" show-overflow-tooltip></el-table-column>
  364. </el-table>
  365. </div>
  366. <div class="pagination clearfix">
  367. <div class="fr">
  368. <el-pagination
  369. @current-change="dialogTableCurrentChange"
  370. :current-page="dialogTable_currentPage"
  371. :page-size="dialogTable_pageSize"
  372. background
  373. layout="prev, pager, next"
  374. :total="dialogTable_listTotal">
  375. </el-pagination>
  376. </div>
  377. </div>
  378. <div slot="footer" class="dialog-footer">
  379. <el-button @click="isShowDialog = false">关 闭</el-button>
  380. </div>
  381. </el-dialog>
  382. <el-dialog title="添加产品" :visible.sync="isShowGoodsDialog" width="80%">
  383. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  384. <el-row :gutter="20">
  385. <el-col :xs="12" :sm="6" :lg="6">
  386. <el-form-item prop="proNum">
  387. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码"></el-input>
  388. </el-form-item>
  389. </el-col>
  390. <el-col :xs="12" :sm="6" :lg="6">
  391. <el-form-item prop="proName">
  392. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称"></el-input>
  393. </el-form-item>
  394. </el-col>
  395. <el-col :xs="12" :sm="6" :lg="6">
  396. <el-form-item prop="proModel">
  397. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号"></el-input>
  398. </el-form-item>
  399. </el-col>
  400. <el-col :xs="12" :sm="6" :lg="6">
  401. <el-form-item prop="price1" style="display: flex">
  402. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  403. <span> - </span>
  404. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  405. </el-form-item>
  406. </el-col>
  407. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  408. <el-form-item label="">
  409. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  410. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  411. </el-form-item>
  412. </el-col>
  413. </el-row>
  414. </el-form>
  415. <div class="tables">
  416. <div class="table">
  417. <el-table :data="leftGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="leftSelectionChange">
  418. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  419. <el-table-column align="center" label="销售类型" prop="saleName" min-width="100" show-overflow-tooltip></el-table-column>
  420. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  421. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  422. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  423. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  424. </el-table>
  425. <div class="pagination clearfix" style="margin-top: 10px">
  426. <div class="fr">
  427. <el-pagination
  428. @current-change="handleTableCurrentChange"
  429. :current-page="currentPage"
  430. :page-size="10"
  431. background
  432. layout="prev, pager, next"
  433. :total="listTotal">
  434. </el-pagination>
  435. </div>
  436. </div>
  437. </div>
  438. <div class="buttons">
  439. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  440. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  441. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  442. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  443. </div>
  444. <div class="table">
  445. <el-table :data="rightGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="rightSelectionChange">
  446. <el-table-column align="center" type="selection" width="55"></el-table-column>
  447. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  448. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  449. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  450. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  451. </el-table>
  452. </div>
  453. </div>
  454. <span slot="footer" class="dialog-footer">
  455. <el-button @click="closeDialog">取 消</el-button>
  456. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  457. </span>
  458. </el-dialog>
  459. </div>
  460. </template>
  461. <script>
  462. import { getOrderDetail, getHomeLoginList, getHomeLoginDetail, getWarehouseList, addHome, editHome, submitHome, checkStock, getRetailProductList } from "@/api/supply/engin";
  463. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  464. import { findElem } from '@/utils/util'
  465. let that
  466. export default {
  467. name: 'HomeForm',
  468. componentName: 'HomeForm',
  469. props: ['listItem'],
  470. filters: {
  471. status1Filter(val) {
  472. let STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue;
  473. let STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue;
  474. let STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue;
  475. let STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue;
  476. let 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. data() {
  485. return {
  486. editId: '',
  487. mainForm: {
  488. customerId: '',
  489. orderNum: '',
  490. orderDate: '',
  491. type: '',
  492. jxsNum: '',
  493. jxsName: '',
  494. loginNum: '',
  495. enginName: '',
  496. loginType: '',
  497. promiseStatus: '',
  498. factoryNum: '',
  499. company: '',
  500. saleType: '',
  501. contactMan: '',
  502. tel: '',
  503. phone: '',
  504. address: '',
  505. declareNo: '',
  506. greeRemark: '',
  507. greeReply: '',
  508. remark: '',
  509. createMan: '',
  510. createDate: '',
  511. fileNum: '',
  512. loginUserId: '',
  513. salesMan: '',
  514. projectRemark: '',
  515. projectType: '',
  516. examineRemark: '',
  517. refCount: '',
  518. regionWork: '',
  519. examineStatus: '',
  520. refBuyUnitName: '',
  521. refPromiseProvide: '',
  522. },
  523. mainFormRules: {
  524. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  525. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  526. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  527. loginNum: [{ required: true, message: '请输入工程登录编号', trigger: 'blur' }],
  528. // enginName: [{ required: true, message: '请输入项目类别', trigger: 'blur' }],
  529. // loginType: [{ required: true, message: '请输入行业类别', trigger: 'blur' }],
  530. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  531. saleType: [{ required: true, message: '请选择销售类型', trigger: 'change' }],
  532. // contactMan: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  533. // tel: [{ required: true, message: '请输入固定电话', trigger: 'blur' }],
  534. // phone: [{ required: true, message: '请输入移动电话', trigger: 'blur' }],
  535. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  536. },
  537. salesTypeList: [],
  538. // typeList: [],
  539. stockList: [],
  540. goodsList: [],
  541. isShowDialog: false, // 工程登录列表 - 弹窗
  542. screenForm: {
  543. loginNum: '',
  544. enginName: '',
  545. company: '',
  546. },
  547. dialogTable_dataList: null, // 工程登录列表 - 列表数据
  548. dialogTable_listLoading: true, // 工程登录列表 - 列表加载loading
  549. dialogTable_currentPage: 1, // 工程登录列表 - 当前页码
  550. dialogTable_pageSize: 10, // 工程登录列表 - 每页数量
  551. dialogTable_listTotal: 0, // 工程登录列表 - 列表总数
  552. warehouseList: [],
  553. warehouseValue: '',
  554. isShowGoodsDialog: false,
  555. goodsScreenForm: {
  556. proNum: '',
  557. proName: '',
  558. proModel: '',
  559. price1: '',
  560. price2: '',
  561. },
  562. currentPage: 1,
  563. listTotal: 0,
  564. leftGoodsList: [],
  565. rightGoodsList: [],
  566. leftSelection: [],
  567. rightSelection: [],
  568. formLoading: false,
  569. isFirst: false,
  570. salesmanList: [],
  571. oldSaleType: '',
  572. notInRefQueryGoodsList: ''
  573. }
  574. },
  575. computed: {
  576. isDealer() {
  577. return JSON.parse(localStorage.getItem("supply_user")).isCustomer
  578. },
  579. outSalesmanList() {
  580. let list = [];
  581. if(this.goodsList && this.goodsList.length) {
  582. this.goodsList.forEach(item => {
  583. if(item.serviceId) {
  584. let hasItem = findElem(list, 'adminUserId', item.serviceId);
  585. if(hasItem < 0) {
  586. let 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. if(this.goodsList && this.goodsList.length) {
  606. if(this.isFirst) {
  607. this.isFirst = false;
  608. }else {
  609. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  610. }
  611. }else {
  612. this.mainForm.salesMan = '';
  613. }
  614. },
  615. immediate: true,
  616. deep: true
  617. },
  618. 'mainForm.saleType': function (newValue, oldValue) {
  619. this.oldSaleType = oldValue
  620. }
  621. },
  622. beforeCreate() {
  623. that = this;
  624. },
  625. async created() {
  626. await this.getSalesmanList();
  627. this.getDictList();
  628. this.getSalesTypeList();
  629. this.getWarehouseList();
  630. if(this.listItem) {
  631. this.isFirst = true;
  632. this.editId = this.listItem.parentId;
  633. this.getDetail();
  634. }else {
  635. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  636. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  637. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  638. this.mainForm.createDate = this.getDate();
  639. }
  640. },
  641. methods: {
  642. // 返回列表
  643. goBack() {
  644. this.$emit('backListFormDetail');
  645. },
  646. getDate() {
  647. var date = new Date();
  648. var seperator1 = "-";
  649. var year = date.getFullYear();
  650. var month = date.getMonth() + 1;
  651. var strDate = date.getDate();
  652. if (month >= 1 && month <= 9) {
  653. month = "0" + month;
  654. }
  655. if (strDate >= 0 && strDate <= 9) {
  656. strDate = "0" + strDate;
  657. }
  658. var currentdate = year + seperator1 + month + seperator1 + strDate;
  659. return currentdate;
  660. },
  661. // 获取产品大类列表
  662. getDictList() {
  663. // getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  664. // this.typeList = res.data;
  665. // })
  666. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  667. this.stockList = res.data;
  668. })
  669. },
  670. // 获取销售类型列表
  671. getSalesTypeList() {
  672. getTypeList({
  673. pageNum: 1,
  674. pageSize: -1
  675. }).then((res) => {
  676. this.salesTypeList = res.data.records;
  677. })
  678. },
  679. // 获取仓库列表
  680. getWarehouseList() {
  681. getWarehouseList({
  682. pageNum: 1,
  683. pageSize: -1
  684. }).then((res) => {
  685. this.warehouseList = res.data.records;
  686. })
  687. },
  688. async getSalesmanList() {
  689. const res = await getSalesmanList({
  690. pageNum: 1,
  691. pageSize: -1,
  692. isCustomer: 0,
  693. status: true,
  694. });
  695. this.salesmanList = res.data.records;
  696. },
  697. // 工程登录列表 - 获取列表
  698. getHomeLoginList() {
  699. getHomeLoginList({
  700. pageNum: this.dialogTable_currentPage,
  701. pageSize: this.dialogTable_pageSize,
  702. recordNo: this.screenForm.loginNum,
  703. projectName: this.screenForm.enginName,
  704. useUnit: this.screenForm.company,
  705. examineStatus: 'OK'
  706. }).then(res => {
  707. this.dialogTable_dataList = res.data.records;
  708. this.dialogTable_listTotal = res.data.total;
  709. this.dialogTable_listLoading = false;
  710. })
  711. },
  712. // 工程登录列表 - 打开弹窗
  713. openShareDetail() {
  714. if(!this.mainForm.saleType) {
  715. return this.$errorMsg('请先选择销售类型');
  716. }
  717. this.isShowDialog = true;
  718. this.dialogTable_currentPage = 1;
  719. this.screenForm.loginNum = this.mainForm.loginNum;
  720. this.getHomeLoginList();
  721. },
  722. // 工程登录列表 - 更改列表当前页
  723. dialogTableCurrentChange(val) {
  724. this.dialogTable_currentPage = val;
  725. this.getHomeLoginList();
  726. },
  727. // 提交筛选表单
  728. submitScreenForm() {
  729. this.dialogTable_currentPage = 1;
  730. this.getHomeLoginList();
  731. },
  732. // 重置筛选表单
  733. resetScreenForm() {
  734. this.$refs.screenForm.resetFields();
  735. this.dialogTable_currentPage = 1;
  736. this.getHomeLoginList();
  737. },
  738. // 选择工程登录
  739. async chooseItem(id, uid, isChangeSaleType = false) {
  740. let isCustomer = JSON.parse(localStorage.getItem("supply_user")).isCustomer
  741. let customerId = JSON.parse(localStorage.getItem("supply_user")).customerId
  742. if (!isCustomer) {
  743. customerId = this.mainForm.customerId
  744. }
  745. getHomeLoginDetail({
  746. recordNo: id,
  747. saleTypeId: this.mainForm.saleType,
  748. userId: uid,
  749. enginOrderId: this.mainForm.orderNum,
  750. customerId: customerId
  751. }).then(async res => {
  752. // 复制当前明细数据
  753. let copyGoodsList = JSON.parse(JSON.stringify(this.goodsList));
  754. console.log('未刷新前', copyGoodsList)
  755. if (!isChangeSaleType) {
  756. this.setMainAndItem(res.data)
  757. } else {
  758. // 找出不属于引用单上的产品
  759. if (copyGoodsList && copyGoodsList.length > 0) {
  760. let notInRefGoodsList = []
  761. for (let i = 0; i < copyGoodsList.length; i++) {
  762. let goods = copyGoodsList[i]
  763. let index = res.data.items.findIndex(v => v.materialOldNumber === goods.materialOldNumber)
  764. if (index < 0) {
  765. notInRefGoodsList.push(goods)
  766. }
  767. }
  768. if (notInRefGoodsList && notInRefGoodsList.length > 0) {
  769. let oldNumbers = []
  770. notInRefGoodsList.forEach(v => oldNumbers.push(v.materialOldNumber))
  771. console.log('请求前可选机型接口', notInRefGoodsList, oldNumbers)
  772. // 请求可选机型接口
  773. await this.querySaleTypeGoods(oldNumbers)
  774. console.log('返回新加明细', this.notInRefQueryGoodsList)
  775. if (!this.notInRefQueryGoodsList) {
  776. console.log('结束执行下去')
  777. return
  778. }
  779. this.addRefItems(res.data.items, notInRefGoodsList)
  780. }
  781. // 数量和价格不变更
  782. console.log('执行下去,数量和价格不变更')
  783. }
  784. console.log('替换前', res.data.items)
  785. res.data.items = this.replaceHistoryItems(res.data.items, copyGoodsList)
  786. console.log('替换后', res.data.items)
  787. this.setMainAndItem(res.data)
  788. }
  789. }).catch(() => {
  790. this.mainForm.saleType = this.oldSaleType
  791. })
  792. },
  793. // 选择销售类型
  794. changeSaleType() {
  795. if(this.mainForm.loginNum) {
  796. this.chooseItem(this.mainForm.loginNum, this.mainForm.loginUserId, true);
  797. }
  798. },
  799. // 删除产品
  800. deleteItem(index) {
  801. this.goodsList.splice(index, 1);
  802. },
  803. // 修改返利钱包
  804. changeFlWallet(index) {
  805. if(this.goodsList[index].customerWalletId2) {
  806. let obj = this.goodsList[index].rebateWallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2);
  807. this.goodsList[index].rebateRate = obj.rebateRate;
  808. this.goodsList[index].customerWalletName2 = obj.customerWalletName;
  809. }else {
  810. this.goodsList[index].rebateRate = '';
  811. this.goodsList[index].customerWalletName2 = '';
  812. }
  813. },
  814. // 修改现金钱包
  815. changeXjWallet(index) {
  816. if(this.goodsList[index].customerWalletId) {
  817. let obj = this.goodsList[index].wallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId);
  818. this.goodsList[index].customerWalletName = obj.customerWalletName;
  819. this.goodsList[index].serviceId = obj.serviceId;
  820. this.goodsList[index].serviceName = obj.serviceName;
  821. }else {
  822. this.goodsList[index].customerWalletName = '';
  823. this.goodsList[index].serviceId = '';
  824. this.goodsList[index].serviceName = '';
  825. }
  826. },
  827. // 获取详情
  828. getDetail() {
  829. getOrderDetail({id: this.editId}).then(res => {
  830. let data = res.data;
  831. this.mainForm.customerId = data.customerId
  832. this.mainForm.orderNum = data.enginOrderId;
  833. this.mainForm.orderDate = data.orderDate;
  834. this.mainForm.type = data.mainId;
  835. this.mainForm.jxsNum = data.customerNumber;
  836. this.mainForm.jxsName = data.customerName;
  837. this.mainForm.loginNum = data.refEnginRecordNo;
  838. this.mainForm.enginName = data.refProjectCategory;
  839. this.mainForm.loginType = data.refTradeCategory;
  840. this.mainForm.promiseStatus = data.refPromiseStatus;
  841. this.mainForm.factoryNum = data.refFactoryNo;
  842. this.mainForm.company = data.refUseUnit;
  843. this.mainForm.saleType = data.saleTypeId;
  844. this.mainForm.contactMan = data.refLinkman;
  845. this.mainForm.tel = data.refTel;
  846. this.mainForm.phone = data.refPhone;
  847. this.mainForm.address = data.refInstallAddress;
  848. this.mainForm.declareNo = data.refDeclareNo;
  849. this.mainForm.refCount = data.refCount;
  850. this.mainForm.greeRemark = data.geLiInerNote;
  851. this.mainForm.greeReply = data.note1;
  852. this.mainForm.remark = data.remark;
  853. this.mainForm.createMan = data.createBy;
  854. this.mainForm.createDate = data.createTime;
  855. this.mainForm.fileNum = data.fileNo;
  856. this.mainForm.salesMan = data.serviceId;
  857. this.mainForm.projectRemark = data.refProjectNote;
  858. this.mainForm.projectType = data.refProjectType;
  859. this.mainForm.examineRemark = data.examineNote;
  860. this.mainForm.loginUserId = data.loginUserId;
  861. this.mainForm.regionWork = data.refRegionWork;
  862. this.mainForm.examineStatus = data.examineStatus;
  863. this.mainForm.refBuyUnitName = data.refBuyUnitName;
  864. this.mainForm.refPromiseProvide = data.refPromiseProvide;
  865. data.items.forEach(item => {
  866. item.status1 = '';
  867. item.status2 = '';
  868. item.rebateWallets = item.customerWalletList.filter(item => {
  869. return item.type === 'REBATE';
  870. });
  871. item.wallets = item.customerWalletList.filter(item => {
  872. return item.type === 'COMMONLY';
  873. });
  874. })
  875. this.goodsList = data.items;
  876. })
  877. },
  878. // 获取商品列表
  879. getGoodsList() {
  880. getRetailProductList({
  881. pageNum: this.currentPage,
  882. pageSize: 10,
  883. saleId: this.mainForm.saleType,
  884. billType: 'HOME',
  885. materialCode: this.goodsScreenForm.proNum,
  886. materialName: this.goodsScreenForm.proName,
  887. specification: this.goodsScreenForm.proModel,
  888. price1: this.goodsScreenForm.price1,
  889. price2: this.goodsScreenForm.price2,
  890. customerId:this.listItem ?this.listItem.customerId :'' ,
  891. }).then(res => {
  892. let oldGoodsList = this.goodsList;
  893. let newGoodsList = res.data.records;
  894. for(let i = 0; i < oldGoodsList.length; i++) {
  895. let oldItem = oldGoodsList[i]
  896. for(let j = 0; j < newGoodsList.length; j++) {
  897. let newItem = newGoodsList[j]
  898. if(newItem.id === oldItem.id){
  899. newGoodsList[j].selected = true;
  900. break;
  901. }
  902. }
  903. }
  904. res.data.records.forEach(item => {
  905. item.materialName = item.name;
  906. item.materialCode = item.number;
  907. item.saleTypeName = item.saleName;
  908. item.unit = item.baseUnit;
  909. item.enginNum = 0;
  910. item.qty = 0;
  911. item.price = item.batchPrice;
  912. item.tax = item.taxRate;
  913. item.isDirectTransfer = false;
  914. item.directTransferQty = '';
  915. item.status1 = '';
  916. item.status2 = '';
  917. item.rebateAmount = '';
  918. item.rebateRate = '';
  919. item.productPriceId = item.id;
  920. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  921. });
  922. this.leftGoodsList = res.data.records;
  923. this.listTotal = res.data.total;
  924. })
  925. },
  926. // 查询重复值并禁选
  927. checkboxSelect(row, rowIndex) {
  928. if (row.selected) {
  929. return false // 禁用
  930. }else{
  931. return true // 不禁用
  932. }
  933. },
  934. // 点击 选择商品
  935. openDialog() {
  936. if(!this.mainForm.saleType) {
  937. return this.$errorMsg('请先选择销售类型');
  938. }
  939. this.isShowGoodsDialog = true;
  940. this.getGoodsList();
  941. },
  942. // 提交筛选表单
  943. submitGoodsScreenForm() {
  944. this.currentPage = 1;
  945. this.getGoodsList();
  946. },
  947. // 重置筛选表单
  948. resetGoodsScreenForm() {
  949. this.$refs.goodsScreenForm.resetFields();
  950. this.currentPage = 1;
  951. this.getGoodsList();
  952. },
  953. // 更改列表当前页
  954. handleTableCurrentChange(val) {
  955. this.currentPage = val;
  956. this.getGoodsList();
  957. },
  958. // 关闭 弹窗
  959. closeDialog() {
  960. this.isShowGoodsDialog = false;
  961. },
  962. // 左侧列表选择
  963. leftSelectionChange(val) {
  964. this.leftSelection = val;
  965. },
  966. // 右侧列表选择
  967. rightSelectionChange(val) {
  968. this.rightSelection = val;
  969. },
  970. // 数组去重
  971. delRepeat(arr1, arr2) {
  972. let allArr = arr1.concat(arr2); // 两个数组对象合并
  973. let newArr = []; // 存放去重后数据的新数组
  974. for(let i=0; i<allArr.length; i++){ // 循环allArr数组对象的内容
  975. let flag = true; // 建立标记,判断数据是否重复,true为不重复
  976. for(let j=0; j<newArr.length; j++){ // 循环新数组的内容
  977. if(allArr[i].id == newArr[j].id){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  978. flag = false;
  979. }
  980. }
  981. if(flag){ // 判断是否重复
  982. newArr.push(allArr[i]); // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  983. }
  984. }
  985. return newArr;
  986. },
  987. // 全部添加
  988. addAllGoods() {
  989. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList);
  990. },
  991. // 添加
  992. addGoods() {
  993. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList);
  994. },
  995. // 删除
  996. deleteGoods() {
  997. let rightGoodsList = this.rightGoodsList;
  998. let rightSelection = this.rightSelection;
  999. for(let i = 0; i < rightGoodsList.length; i++) {
  1000. for(let j = 0; j < rightSelection.length; j++) {
  1001. if(rightSelection[j].materialId == rightGoodsList[i].materialId){
  1002. this.rightGoodsList.splice(i, 1);
  1003. }
  1004. }
  1005. }
  1006. },
  1007. // 全部删除
  1008. deleteAllGoods() {
  1009. this.rightGoodsList = [];
  1010. },
  1011. // 确定 添加产品
  1012. submitAddGoods() {
  1013. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  1014. this.goodsList = this.goodsList.concat(this.rightGoodsList);
  1015. this.isShowGoodsDialog = false;
  1016. this.leftGoodsList = [];
  1017. this.rightGoodsList = [];
  1018. },
  1019. // 检查库存
  1020. checkStock() {
  1021. if(!this.warehouseValue) {
  1022. return this.$errorMsg('请选择仓库');
  1023. }
  1024. if(!this.goodsList) {
  1025. return this.$errorMsg('请添加货品');
  1026. }
  1027. let ids = [];
  1028. this.goodsList.forEach(item => {
  1029. ids.push(item.materialId);
  1030. })
  1031. checkStock({
  1032. correspondId: this.warehouseValue,
  1033. materialId: ids.join(',')
  1034. }).then(res => {
  1035. if(res.data) {
  1036. this.goodsList.forEach((item, index) => {
  1037. item.status1 = res.data[index].allStockNum;
  1038. item.status2 = res.data[index].stockNum;
  1039. })
  1040. }
  1041. })
  1042. },
  1043. status2Filter(item) {
  1044. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查';
  1045. else if (item.status2 <= 0) return '无货';
  1046. if ( item.status2 <= 0 ) {
  1047. return '无货'
  1048. }else if(item.status2 >= 1 && item.status2 <= 30){
  1049. return item.status2
  1050. }else if(item.status2 >=31 && item.status2 <= 1000 ){
  1051. return '有货'
  1052. }else{
  1053. return '充足'
  1054. }
  1055. },
  1056. // 保存 / 提交审核
  1057. clickSubmitForm(type) {
  1058. this.$refs.mainForm.validate((valid) => {
  1059. if (valid) {
  1060. for(let i=0; i<this.goodsList.length; i++) {
  1061. if(!this.goodsList[i].customerWalletId) {
  1062. this.$errorMsg('请选择现金钱包');
  1063. return;
  1064. }
  1065. if(type ==1){
  1066. if(!this.goodsList[i].qty) {
  1067. this.$errorMsg('金额不能为0');
  1068. return;
  1069. }
  1070. }
  1071. }
  1072. let goodsList = JSON.parse(JSON.stringify(this.goodsList));
  1073. goodsList.forEach(item => {
  1074. delete item.rebateWallets;
  1075. delete item.wallets;
  1076. })
  1077. let saleTypeItem = this.salesTypeList.find(o => o.id == this.mainForm.saleType);
  1078. let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
  1079. let params = {
  1080. enginOrderId: this.mainForm.orderNum,
  1081. loginUserId: this.mainForm.loginUserId,
  1082. refEnginRecordNo: this.mainForm.loginNum || '',
  1083. refProjectCategory: this.mainForm.enginName || '',
  1084. refTradeCategory: this.mainForm.loginType || '',
  1085. refPromiseStatus: this.mainForm.promiseStatus || '',
  1086. refFactoryNo: this.mainForm.factoryNum || '',
  1087. refUseUnit: this.mainForm.company || '',
  1088. refLinkman: this.mainForm.contactMan || '',
  1089. refTel: this.mainForm.tel || '',
  1090. refPhone: this.mainForm.phone || '',
  1091. refInstallAddress: this.mainForm.address || '',
  1092. refDeclareNo: this.mainForm.declareNo || '',
  1093. refCount: this.mainForm.refCount || '',
  1094. saleTypeId: this.mainForm.saleType,
  1095. saleTypeCode: saleTypeItem.saleCode,
  1096. saleTypeName: saleTypeItem.saleName,
  1097. geLiInerNote: this.mainForm.greeRemark || '',
  1098. geLiNote: this.mainForm.greeReply || '',
  1099. remark: this.mainForm.remark || '',
  1100. fileNo: this.mainForm.fileNum || '',
  1101. serviceId: this.mainForm.salesMan,
  1102. serviceName: saleManItem ? saleManItem.nickName : goodsList[0].serviceName,
  1103. refProjectNote: this.mainForm.projectRemark,
  1104. refProjectType: this.mainForm.projectType,
  1105. refRegionWork: this.mainForm.regionWork,
  1106. refBuyUnitName: this.mainForm.refBuyUnitName,
  1107. refPromiseProvide: this.mainForm.refPromiseProvide,
  1108. items: goodsList,
  1109. }
  1110. this.formLoading = true;
  1111. if(type === 1) {
  1112. if(this.listItem) {
  1113. editHome(params).then(res => {
  1114. this.$successMsg('编辑成功');
  1115. this.goBack();
  1116. this.$parent.getList();
  1117. }).finally(res => {
  1118. this.formLoading = false;
  1119. })
  1120. }else {
  1121. addHome(params).then(res => {
  1122. this.$successMsg('新增成功');
  1123. this.goBack();
  1124. this.$parent.getList();
  1125. }).finally(res => {
  1126. this.formLoading = false;
  1127. })
  1128. }
  1129. }else if(type === 2) {
  1130. submitHome(params).then(res => {
  1131. this.$successMsg('提交审核成功');
  1132. this.goBack();
  1133. this.$parent.getList();
  1134. }).finally(res => {
  1135. this.formLoading = false;
  1136. })
  1137. }
  1138. }
  1139. })
  1140. },
  1141. setMainAndItem(data) {
  1142. this.isShowDialog = false;
  1143. this.mainForm.type = data.productCategory;
  1144. this.mainForm.loginUserId = data.userid;
  1145. // this.mainForm.saleType = '';
  1146. this.mainForm.loginNum = data.recordNo;
  1147. this.mainForm.enginName = data.projectName;
  1148. this.mainForm.loginType = data.tradeCategory;
  1149. this.mainForm.factoryNum = data.factoryNo;
  1150. this.mainForm.promiseStatus = data.promiseStatus;
  1151. this.mainForm.company = data.useUnit;
  1152. this.mainForm.contactMan = data.buyUnitCallMen;
  1153. this.mainForm.tel = data.buyUnitTel;
  1154. this.mainForm.phone = data.buyUnitPhone;
  1155. this.mainForm.address = data.installAddress;
  1156. this.mainForm.declareNo = data.declareNo;
  1157. this.mainForm.projectRemark = data.buChonShuoMing;
  1158. this.mainForm.projectType = data.govBuyType;
  1159. this.mainForm.refCount = data.refCount;
  1160. this.mainForm.regionWork = data.regionWork;
  1161. this.mainForm.refBuyUnitName = data.buyUnitName;
  1162. this.mainForm.refPromiseProvide = data.promiseProvide === 1 ? '已保证':'未保证';
  1163. let saleTypeItem = this.salesTypeList.find(o => o.id === this.mainForm.saleType);
  1164. this.goodsList = data.items.map(item => {
  1165. return {
  1166. useRefCount: item.useRefCount,
  1167. saleTypeId: saleTypeItem.id,
  1168. saleTypeCode: saleTypeItem.saleCode,
  1169. saleTypeName: saleTypeItem.saleName,
  1170. materialId: item.materialId,
  1171. materialNumber: item.materialNumber,
  1172. materialOldNumber: item.materialOldNumber,
  1173. materialName: item.materialName,
  1174. specification: item.machine,
  1175. enginNum: item.num,
  1176. enginPrice: item.price,
  1177. enginTotality: item.totality,
  1178. historyHasDeliverQty: item.hasDeliverQty,
  1179. unit: item.unit,
  1180. price: item.price,
  1181. qty: item.num,
  1182. customerWalletId2: '',
  1183. rebateRate: '',
  1184. discAmount: '',
  1185. customerWalletId: '',
  1186. isDirectTransfer: false,
  1187. directTransferQty: '',
  1188. hasSendQty: '',
  1189. remark: item.discri,
  1190. tax: '',
  1191. status1: '',
  1192. status2: '',
  1193. rebateWallets: item.customerWalletList.filter(item => {
  1194. return item.type === 'REBATE';
  1195. }),
  1196. wallets: item.customerWalletList.filter(item => {
  1197. return item.type === 'COMMONLY';
  1198. }),
  1199. }
  1200. })
  1201. this.goodsList.forEach(item => {
  1202. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  1203. item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
  1204. item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
  1205. })
  1206. },
  1207. async querySaleTypeGoods(oldNumbers) {
  1208. await getRetailProductList({
  1209. pageNum: 1,
  1210. pageSize: -1,
  1211. saleId: this.mainForm.saleType,
  1212. billType: 'HOME',
  1213. oldNumbers: oldNumbers.join(','),
  1214. customerId: this.mainForm.customerId
  1215. }).then(res => {
  1216. console.log('请求后可选机型接口', res.data.records)
  1217. if (!res.data.records || res.data.records.length === 0) {
  1218. this.mainForm.saleType = this.oldSaleType
  1219. console.log(1)
  1220. this.$errorMsg(oldNumbers.join(',') + " 产品无此销售类型")
  1221. this.notInRefQueryGoodsList = ''
  1222. return
  1223. }
  1224. if (res.data.records.length < oldNumbers.length) {
  1225. let notInOldNumbers = []
  1226. for (let i = 0; i < oldNumbers.length; i++) {
  1227. let oldNumber = oldNumbers[i]
  1228. let index = res.data.records.findIndex(v => v.materialOldNumber === oldNumber)
  1229. if (index < 0) {
  1230. notInOldNumbers.push(oldNumber)
  1231. }
  1232. }
  1233. this.mainForm.saleType = this.oldSaleType
  1234. console.log(2)
  1235. this.$errorMsg(notInOldNumbers.join(',') + " 产品无此销售类型")
  1236. this.notInRefQueryGoodsList = ''
  1237. return
  1238. }
  1239. this.notInRefQueryGoodsList = res.data.records
  1240. })
  1241. },
  1242. replaceHistoryItems(items, copyGoodsList) {
  1243. if (items && copyGoodsList) {
  1244. for (let i = 0; i < items.length; i++) {
  1245. let index = copyGoodsList.findIndex(v => v.materialOldNumber === items[i].materialOldNumber)
  1246. if (index >= 0) {
  1247. items[i].price = copyGoodsList[index].price
  1248. items[i].num = copyGoodsList[index].qty
  1249. items[i].discri = copyGoodsList[index].remark
  1250. }
  1251. }
  1252. }
  1253. return items
  1254. },
  1255. addRefItems(items, notInRefGoodsList) {
  1256. if (notInRefGoodsList && this.notInRefQueryGoodsList) {
  1257. for (let i = 0; i < notInRefGoodsList.length; i++) {
  1258. let index = this.notInRefQueryGoodsList.findIndex(v => v.materialOldNumber === notInRefGoodsList[i].materialOldNumber)
  1259. if (index >= 0) {
  1260. this.notInRefQueryGoodsList[index].batchPrice = notInRefGoodsList[i].price
  1261. this.notInRefQueryGoodsList[index].qty = notInRefGoodsList[i].qty
  1262. this.notInRefQueryGoodsList[index].remark = notInRefGoodsList[i].remark
  1263. }
  1264. }
  1265. console.log('非引用单产品', this.notInRefQueryGoodsList)
  1266. for (let i = 0; i < this.notInRefQueryGoodsList.length; i++) {
  1267. let goods = this.notInRefQueryGoodsList[i]
  1268. let customerWalletList = [].concat(goods.rebateWallets).concat(goods.wallets)
  1269. items.push({
  1270. saleTypeId: goods.saleTypeId,
  1271. saleTypeCode: goods.saleTypeCode,
  1272. saleTypeName: goods.saleTypeName,
  1273. materialId: goods.materialId,
  1274. materialNumber: goods.materialNumber,
  1275. materialOldNumber: goods.materialOldNumber,
  1276. materialName: goods.materialName,
  1277. machine: goods.specification,
  1278. num: goods.qty,
  1279. batchPrice: goods.batchPrice,
  1280. discri: goods.remark,
  1281. customerWalletList: customerWalletList
  1282. })
  1283. }
  1284. }
  1285. }
  1286. }
  1287. }
  1288. </script>
  1289. <style scoped lang="scss">
  1290. .detail-container {
  1291. width: 100%;
  1292. height: 100%;
  1293. }
  1294. .main-title {
  1295. display: flex;
  1296. justify-content: space-between;
  1297. align-items: center;
  1298. margin-top: 20px;
  1299. height: 60px;
  1300. border-bottom: 1px solid #DCDFE6;
  1301. margin-bottom: 20px;
  1302. .title {
  1303. font-size: 16px;
  1304. font-weight: 600;
  1305. padding-left: 10px;
  1306. }
  1307. }
  1308. .tables {
  1309. display: flex;
  1310. margin-top: 10px;
  1311. .table {
  1312. width: 45%;
  1313. }
  1314. .buttons {
  1315. display: flex;
  1316. flex-direction: column;
  1317. justify-content: center;
  1318. align-items: center;
  1319. padding: 0 10px;
  1320. button {
  1321. margin: 0;
  1322. margin-top: 10px;
  1323. }
  1324. }
  1325. }
  1326. ::v-deep input::-webkit-outer-spin-button,
  1327. ::v-deep input::-webkit-inner-spin-button {
  1328. -webkit-appearance: none;
  1329. }
  1330. ::v-deep input[type='number'] {
  1331. -moz-appearance: textfield;
  1332. }
  1333. </style>