btnAdd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div>
  3. <el-button
  4. size="small"
  5. type="primary"
  6. @click="addBtn((drawerVisible = true))"
  7. >{{ $t(btnTitle)}}</el-button
  8. >
  9. <el-drawer
  10. :title="$t(drawerTitle)"
  11. :visible.sync="drawerVisible"
  12. size="80%"
  13. direction="rtl"
  14. append-to-body
  15. :show-close="false"
  16. @close="onClose">
  17. <div class="drawer__panel" style="margin-bottom: 0 !important;">
  18. <div class="flex-between" v-if="drawerTitle == '自产品档案添加'">
  19. <el-select
  20. v-model="where.sa_brandid"
  21. :placeholder="$t(`选择品牌`)"
  22. size="small"
  23. clearable
  24. class="inline-24"
  25. @change="brandChange"
  26. >
  27. <el-option
  28. v-for="item in options.brands"
  29. :key="item.sa_brandid"
  30. :label="$t(item.brandname)"
  31. :value="item.sa_brandid"
  32. >
  33. </el-option>
  34. </el-select>
  35. <el-cascader
  36. :placeholder="$t(`选择分类`)"
  37. size="small"
  38. v-model="itemclassid"
  39. :options="options.itemclass"
  40. :props="{
  41. checkStrictly: true,
  42. children: 'subdep',
  43. label: 'itemclassname',
  44. value: 'itemclassid',
  45. }"
  46. clearable
  47. @change="classChange"
  48. ></el-cascader>
  49. </div>
  50. <div class="top-margin" v-if="drawerTitle == '自产品档案添加'">
  51. <el-button
  52. size="small"
  53. :type="selectList.length == 0?'':'primary'"
  54. :loading="loading"
  55. @click="onSubmit"
  56. class="normal-btn-width inline-24"
  57. :disabled="selectList.length == 0"
  58. >{{ $t("添加选中商品") }}</el-button
  59. >
  60. <el-input style="width:200px;" :placeholder="$t('搜索')" :suffix-icon="param.content.where.condition?param.content.where.condition.length > 0?'':'':'el-icon-search'"
  61. v-model="param.content.where.condition" @keyup.native.enter="listData(param.content.pageNumber = 1)" @clear="listData(param.content.pageNumber = 1)"
  62. size="small" class="input-with-select inline-24 layout_search__panel" clearable>
  63. </el-input>
  64. <el-select
  65. v-model="where.standards"
  66. :placeholder="$t(`选择标准`)"
  67. size="small"
  68. clearable
  69. class="inline-24 bottom-margin"
  70. @change="selectChange"
  71. >
  72. <el-option
  73. v-for="item in options.itemstandards"
  74. :key="item.value"
  75. :label="$t(item.value)"
  76. :value="item.value"
  77. >
  78. <span style="float: left">{{ $t(item.value) }}</span>
  79. <span style="float: right; color: #8492a6; font-size: 12px">{{
  80. item.remarks ? $t(item.remarks) : $t("暂无描述")
  81. }}</span>
  82. </el-option>
  83. </el-select>
  84. <el-select
  85. v-model="where.material"
  86. :placeholder="$t(`选择材质`)"
  87. size="small"
  88. clearable
  89. class="inline-24 bottom-margin"
  90. @change="selectChange"
  91. >
  92. <el-option
  93. v-for="item in options.itemmaterials"
  94. :key="item.value"
  95. :label="$t(item.value)"
  96. :value="item.value"
  97. >
  98. <span style="float: left">{{ $t(item.value) }}</span>
  99. <span style="float: right; color: #8492a6; font-size: 12px">{{
  100. item.remarks ? $t(item.remarks) : $t("暂无描述")
  101. }}</span>
  102. </el-option>
  103. </el-select>
  104. <el-input
  105. style="width: 200px"
  106. :placeholder="$t(`型号`)"
  107. :suffix-icon="
  108. where.model
  109. ? where.model.length > 0
  110. ? ''
  111. : ''
  112. : 'el-icon-search'
  113. "
  114. v-model="where.model"
  115. @keyup.native.enter="selectChange"
  116. @clear="selectChange"
  117. size="small"
  118. class="bottom-margin input-with-select inline-24 layout_search__panel"
  119. clearable
  120. >
  121. </el-input>
  122. <el-input
  123. style="width: 200px"
  124. :placeholder="$t(`规格`)"
  125. :suffix-icon="
  126. where.spec
  127. ? where.spec.length > 0
  128. ? ''
  129. : ''
  130. : 'el-icon-search'
  131. "
  132. v-model="where.spec"
  133. @keyup.native.enter="selectChange"
  134. @clear="selectChange"
  135. size="small"
  136. class="bottom-margin input-with-select inline-24 layout_search__panel"
  137. clearable
  138. >
  139. </el-input>
  140. </div>
  141. <el-input v-else style="width:200px;" :placeholder="$t('搜索')" :suffix-icon="param.content.where.condition?param.content.where.condition.length > 0?'':'':'el-icon-search'"
  142. v-model="param.content.where.condition" @keyup.native.enter="listData(param.content.pageNumber = 1)" @clear="listData(param.content.pageNumber = 1)"
  143. size="small" class="input-with-select inline-24 layout_search__panel" clearable>
  144. </el-input>
  145. <table-detail :layout="tablecols" :checkbox="true" :data="list" :custom="true" :width="true" :height="tableHieght" minHeight="200px" fixedName="operation"
  146. @selectionChange="selectionChange" >
  147. <template v-slot:customcol="scope">
  148. <div v-if="scope.column.columnname == 'nominalpressure'">
  149. {{tool.nominalPressureSet(scope.column.data[[scope.column.columnname]])}}
  150. </div>
  151. <div v-else>
  152. {{scope.column.data[[scope.column.columnname]] || scope.column.columnname === 'operation'?scope.column.data[[scope.column.columnname]]:'--'}}
  153. </div>
  154. </template>
  155. </table-detail>
  156. <div class="container normal-panel" style="text-align:right;padding-bottom: 0!important;">
  157. <el-pagination
  158. background
  159. @size-change="handleSizeChange"
  160. @current-change="handleCurrentChange"
  161. :current-page="currentPage"
  162. :page-sizes="[50, 100, 150, 200]"
  163. :page-size="50"
  164. layout="total,sizes, prev, pager, next, jumper"
  165. :total="total">
  166. </el-pagination>
  167. </div>
  168. </div>
  169. <div class="fixed__btn__panel">
  170. <el-button
  171. size="small"
  172. @click="drawerVisible = false"
  173. class="normal-btn-width inline-16"
  174. >{{ $t("取 消") }}</el-button
  175. >
  176. <el-button
  177. size="small"
  178. type="primary"
  179. :loading="loading"
  180. @click="onSubmit"
  181. class="normal-btn-width"
  182. :disabled="selectList.length == 0"
  183. >{{ $t("确 定") }}</el-button
  184. >
  185. </div>
  186. </el-drawer>
  187. </div>
  188. </template>
  189. <script>
  190. export default {
  191. name: "btnAdd",
  192. props:['btnTitle','drawerTitle','param','tablecols','sa_workorderid'],
  193. data(){
  194. return {
  195. drawerVisible:false,
  196. tableHieght:this.drawerTitle == '自产品档案添加'?'calc(100vh - 300px)':'calc(100vh - 240px)',
  197. list:[],
  198. currentPage:0,
  199. total:0,
  200. loading:false,
  201. selectList:[],
  202. sa_brandid:"",
  203. itemclassid: "",
  204. itemstandard: "",
  205. itemmaterial: "",
  206. options: {
  207. brands: [],
  208. itemclass: [],
  209. itemstandards: [],
  210. itemmaterials: [],
  211. },
  212. where:{
  213. "condition": "",
  214. "sa_brandid": "",
  215. "itemclassid":"",
  216. "standards": "",
  217. "material": "",
  218. "spec":"",
  219. "model":"",
  220. "tradefield":""
  221. }
  222. }
  223. },
  224. methods:{
  225. addBtn(){
  226. this.drawerVisible = true
  227. this.selectList = []
  228. this.listData(this.param.content.pageNumber = 1)
  229. this.queryBrands()
  230. this.$store.dispatch("optiontypeselect", "itemstandards").then((res) => {
  231. this.options.itemstandards = res.data;
  232. });
  233. this.$store.dispatch("optiontypeselect", "itemmaterial").then((res) => {
  234. this.options.itemmaterials = res.data;
  235. });
  236. },
  237. async listData(){
  238. const res = await this.$api.requested(this.param)
  239. console.log(res.data,'data')
  240. this.list = res.data
  241. this.currentPage = res.pageNumber
  242. this.total = res.total
  243. },
  244. handleSizeChange(val) {
  245. // console.log(`每页 ${val} 条`);
  246. this.param.content.pageSize = val
  247. this.listData()
  248. },
  249. handleCurrentChange(val) {
  250. // console.log(`当前页: ${val}`);
  251. this.param.content.pageNumber = val
  252. this.listData()
  253. },
  254. selectionChange(select){
  255. console.log(select)
  256. this.selectList = select
  257. },
  258. async onSubmit(){
  259. let iteminfos = this.selectList.map(item =>{
  260. return {
  261. "sa_workorder_node_itemsid":0,
  262. "problem_description":item.problem_description,
  263. "processing":item.processing,
  264. "result":item.result,
  265. "reason":item.reason,
  266. "qty":item.qty || 1,
  267. "itemid":item.itemid
  268. }
  269. })
  270. const res = await this.$api.requested({
  271. id:20230215201903,
  272. content:{
  273. sa_workorder_nodeid:0,
  274. sa_workorderid:this.sa_workorderid,
  275. iteminfos:iteminfos
  276. }
  277. })
  278. if (res.code == 0){
  279. this.tool.showMessage(res,()=>{})
  280. }else {
  281. this.drawerVisible = false
  282. this.$emit('addSuccess')
  283. }
  284. },
  285. brandChange(){
  286. this.selectChange()
  287. this.queryClass()
  288. },
  289. /*获取品牌*/
  290. async queryBrands() {
  291. const res = await this.$api.requested({
  292. id: "2026032009554702",
  293. content: {
  294. pageSize: 1000,
  295. where: {
  296. condition: "",
  297. },
  298. },
  299. });
  300. this.options.brands = res.data;
  301. console.log("获取品牌", res.data);
  302. },
  303. /*获取分类*/
  304. async queryClass() {
  305. const res = await this.$api.requested({
  306. id: "2026032010050802",
  307. content: {
  308. sa_brandid: this.where.sa_brandid !== "" ? this.where.sa_brandid : 0,
  309. },
  310. });
  311. let arr = [];
  312. function converTree(node) {
  313. var elNode = {
  314. isdeep: node["isdeep"],
  315. ishide: node["ishide"],
  316. istool: node["istool"],
  317. itemclassfullname: node["itemclassfullname"],
  318. itemclassfullnum: node["itemclassfullnum"],
  319. itemclassid: node["itemclassid"],
  320. itemclassname: node["itemclassname"],
  321. itemclassnum: node["itemclassnum"],
  322. num: node["num"],
  323. parentid: node["parentid"],
  324. rowindex: node["rowindex"],
  325. subdep: [],
  326. };
  327. if (node.subdep.length > 0) {
  328. // 如果存在子节点
  329. for (var index = 0; index < node.subdep.length; index++) {
  330. // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
  331. elNode.subdep.push(converTree(node.subdep[index]));
  332. }
  333. } else {
  334. elNode = {
  335. isdeep: node["isdeep"],
  336. ishide: node["ishide"],
  337. istool: node["istool"],
  338. itemclassfullname: node["itemclassfullname"],
  339. itemclassfullnum: node["itemclassfullnum"],
  340. itemclassid: node["itemclassid"],
  341. itemclassname: node["itemclassname"],
  342. itemclassnum: node["itemclassnum"],
  343. num: node["num"],
  344. parentid: node["parentid"],
  345. rowindex: node["rowindex"],
  346. };
  347. }
  348. return elNode;
  349. }
  350. // this.options.itemclass = arr
  351. res.data[0].ttemclass.forEach((e) => {
  352. arr.push(converTree(e));
  353. });
  354. this.options.itemclass = arr;
  355. return arr;
  356. },
  357. classChange(){
  358. this.where.itemclassid = this.itemclassid[this.itemclassid.length -1]
  359. this.selectChange()
  360. },
  361. selectChange(){
  362. this.param.content.where = this.where
  363. this.listData(this.param.content.pageNumber = 1)
  364. },
  365. onClose(){
  366. this.sa_brandid = ''
  367. this.itemclassid = ''
  368. this.where = {
  369. "condition": "",
  370. "sa_brandid": "",
  371. "itemclassid":"",
  372. "standards": "",
  373. "material": "",
  374. "spec":"",
  375. "model":"",
  376. "tradefield":""
  377. }
  378. this.selectList = []
  379. this.selectChange()
  380. }
  381. },
  382. }
  383. </script>
  384. <style scoped>
  385. .image {
  386. height: 38px;
  387. width: 38px;
  388. margin-top: 0;
  389. }
  390. .top-margin {
  391. margin-top: 20px;
  392. }
  393. .bottom-margin {
  394. margin-bottom: 20px;
  395. }
  396. /deep/ input::-webkit-input-placeholder {
  397. color: #58585d;
  398. }
  399. /deep/ input::-moz-input-placeholder {
  400. color: #58585d;
  401. }
  402. /deep/ input::-ms-input-placeholder {
  403. color: #58585d;
  404. }
  405. </style>