home_form.vue 55 KB

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