commerce_form.vue 36 KB

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