commerce_form.vue 38 KB

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