3f2c62e6370a2133b001ec780ac6a2f0b8692a63.svn-base 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-button class="import" style="float: right;margin-right: 80px;" @click="handleImport">导入</el-button>
  13. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  14. </div>
  15. <div class="search">
  16. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  17. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  18. </el-select>
  19. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  21. </el-select>
  22. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  24. </el-select>
  25. <div ref="selectInput" class="filter-item selectInput">
  26. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  27. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  28. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  29. <ul v-if="arrowUp" class="selectUl">
  30. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  31. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  32. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  33. <li>
  34. <div style="float: right;">
  35. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  36. <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
  37. </div>
  38. </li>
  39. </ul>
  40. </div>
  41. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  42. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  43. </div>
  44. <div class="table">
  45. <el-table
  46. :key="table.tableKey"
  47. v-loading="table.listLoading"
  48. element-loading-text="给我一点时间"
  49. :data="table.list"
  50. border
  51. fit
  52. highlight-current-row
  53. style="width: 98%;"
  54. :row-style="rowStyle"
  55. :cell-style="cellStyle"
  56. class="elTable table-fixed"
  57. @row-click="tableRowClick"
  58. @selection-change="handleSelectionChange"
  59. >
  60. <el-table-column type="selection" align="center" width="50" />
  61. <el-table-column label="序号" align="center" type="index" width="50px">
  62. <template slot-scope="scope">
  63. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="配方名称" min-width="130px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  69. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="配方颜色" min-width="130px" align="center">
  73. <template slot-scope="scope">
  74. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="牲畜类别" min-width="150px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  80. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  81. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="配方类型" min-width="150px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  88. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  89. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  90. </el-select>
  91. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  92. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="来源" min-width="110px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.source }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="备注" min-width="110px" align="center">
  102. <template slot-scope="scope">
  103. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  104. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="是否启用" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  113. <template slot-scope="{row}">
  114. <!-- 新增 -->
  115. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  116. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  117. <!-- 编辑 -->
  118. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  119. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  120. <!-- 编辑保存 -->
  121. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  122. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <!-- 配方详情表 -->
  129. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  130. <p class="recipeDetail" />
  131. <div class="operation">
  132. <el-button class="success" @click="handleCreate2">新增</el-button>
  133. <el-button class="danger" @click="handleDelete2">删除</el-button>
  134. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  135. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  136. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  137. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  138. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  139. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  140. <li>
  141. <a style="width: 130px;">饲料名称</a>
  142. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  143. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  144. </el-select>
  145. </li>
  146. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  147. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  148. <li>
  149. <a style="width: 130px;">搅拌延时</a>
  150. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  151. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  152. </el-select>
  153. </li>
  154. <li>
  155. <a style="width: 130px;">是否锁定牛头数比例</a>
  156. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  157. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  158. </el-select>
  159. </li>
  160. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  161. <li>
  162. <div style="float: right;">
  163. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  164. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  165. </div>
  166. </li>
  167. </ul>
  168. </div>
  169. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  170. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  171. </div>
  172. <div class="table2" style="min-height: 400px;">
  173. <el-table
  174. id="table2"
  175. ref="table2"
  176. :key="table2.tableKey"
  177. v-loading="table2.listLoading"
  178. element-loading-text="给我一点时间"
  179. :data="table2.list"
  180. border
  181. fit
  182. highlight-current-row
  183. style="width: 98%;"
  184. :row-style="rowStyle"
  185. :cell-style="cellStyle"
  186. class="elTable table-fixed"
  187. row-key="id"
  188. show-summary
  189. @selection-change="handleSelectionChange2"
  190. >
  191. <el-table-column type="selection" width="60" />
  192. <el-table-column label="序号" align="center" type="index" width="50px" />
  193. <el-table-column label="饲料组" min-width="110px" align="center">
  194. <template slot-scope="scope">
  195. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  196. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="饲料名称" min-width="130px" align="center">
  200. <template slot-scope="scope">
  201. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  202. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  203. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  204. </el-select>
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  208. <template slot-scope="scope">
  209. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  210. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  216. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  217. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  218. </el-select>
  219. </template>
  220. </el-table-column>
  221. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  222. <template slot-scope="scope">
  223. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  224. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  225. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  226. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  227. </el-select>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="顺序" min-width="100px" align="center">
  231. <template slot-scope="scope">
  232. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  233. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  237. <template slot-scope="{row}">
  238. <!-- 新增 -->
  239. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  240. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  241. <!-- 编辑 -->
  242. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  243. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  244. <!-- 编辑保存 -->
  245. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  246. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  247. <!-- 拆分预混料 -->
  248. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. </div>
  253. </div>
  254. <!-- 配方记录 -->
  255. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  256. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  257. <div ref="templateDialog" class="templateDialog">
  258. <p class="recipeTemplate" />
  259. <div class="operation">
  260. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  261. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  262. </div>
  263. <div class="search">
  264. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  265. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  266. </el-select>
  267. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  268. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  269. </el-select>
  270. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  271. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  272. </el-select>
  273. <div ref="selectInput" class="filter-item selectInput">
  274. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  275. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  276. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  277. <ul v-if="arrowUp" class="selectUl">
  278. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  279. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  280. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  281. <li>
  282. <div style="float: right;">
  283. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  284. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  285. </div>
  286. </li>
  287. </ul>
  288. </div>
  289. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  290. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  291. </div>
  292. <div class="table">
  293. <el-table
  294. :key="template.table.tableKey"
  295. v-loading="template.table.listLoading"
  296. element-loading-text="给我一点时间"
  297. :data="template.table.list"
  298. border
  299. fit
  300. highlight-current-row
  301. style="width: 98%;"
  302. :row-style="rowStyle"
  303. :cell-style="cellStyle"
  304. class="elTable table-fixed"
  305. @row-click="tableRowClickDialog"
  306. >
  307. <el-table-column label="序号" align="center" type="index" width="50px">
  308. <template slot-scope="scope">
  309. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="配方名称" min-width="130px" align="center">
  313. <template slot-scope="scope">
  314. <span>{{ scope.row.tname }}</span>
  315. </template>
  316. </el-table-column>
  317. <el-table-column label="配方颜色" min-width="130px" align="center">
  318. <template slot-scope="scope">
  319. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="牲畜类别" min-width="150px" align="center">
  323. <template slot-scope="scope">
  324. <span>{{ scope.row.ccname }}</span>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="配方类型" min-width="150px" align="center">
  328. <template slot-scope="scope">
  329. <span>{{ scope.row.fttype }}</span>
  330. </template>
  331. </el-table-column>
  332. <el-table-column label="来源" min-width="110px" align="center">
  333. <template slot-scope="scope">
  334. <span>{{ scope.row.source }}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="备注" min-width="110px" align="center">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.remark }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="是否启用" min-width="110px" align="center">
  343. <template slot-scope="scope">
  344. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  345. </template>
  346. </el-table-column>
  347. </el-table>
  348. </div>
  349. </div>
  350. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  351. <p class="recipeDetail" />
  352. <div class="operation">
  353. <div ref="selectInput2" class="filter-item selectInput">
  354. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  355. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  356. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  357. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  358. <li>
  359. <a style="width: 130px;">饲料名称</a>
  360. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  361. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  362. </el-select>
  363. </li>
  364. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  365. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  366. <li>
  367. <a style="width: 130px;">搅拌延时</a>
  368. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  369. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  370. </el-select>
  371. </li>
  372. <li>
  373. <a style="width: 130px;">是否锁定牛头数比例</a>
  374. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  375. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  376. </el-select>
  377. </li>
  378. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  379. <li>
  380. <div style="float: right;">
  381. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  382. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  383. </div>
  384. </li>
  385. </ul>
  386. </div>
  387. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  388. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  389. </div>
  390. <div class="table2">
  391. <el-table
  392. :key="template.table2.tableKey"
  393. v-loading="template.table2.listLoading"
  394. element-loading-text="给我一点时间"
  395. :data="template.table2.list"
  396. border
  397. fit
  398. highlight-current-row
  399. style="width: 98%;"
  400. :row-style="rowStyle"
  401. :cell-style="cellStyle"
  402. class="elTable table-fixed"
  403. row-key="id"
  404. >
  405. <el-table-column label="饲料组" min-width="130px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.feedgroup }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="饲料名称" min-width="130px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.fname }}</span>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="重量(KG)" min-width="130px" align="center">
  416. <template slot-scope="scope">
  417. <span>{{ scope.row.fweight }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  421. <template slot-scope="scope">
  422. <span>{{ scope.row.autosecondname }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  426. <template slot-scope="scope">
  427. <span v-if="scope.row.islockcount == '0'">否</span>
  428. <span v-if="scope.row.islockcount == '1'">是</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="顺序" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.sort }}</span>
  434. </template>
  435. </el-table-column>
  436. </el-table>
  437. </div>
  438. </div>
  439. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  440. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  441. </div>
  442. </div>
  443. </el-dialog>
  444. <!-- 合成预混料 -->
  445. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  446. <div class="detailDialog">
  447. <h2>饲料</h2>
  448. <div class="table1">
  449. <el-table
  450. :key="detail.tableKey"
  451. v-loading="detail.listLoading"
  452. element-loading-text="给我一点时间"
  453. :data="detail.list"
  454. fit
  455. highlight-current-row
  456. style="width: 100%;"
  457. :row-style="rowStyle"
  458. :cell-style="cellStyle"
  459. class="elTable table-fixed"
  460. show-summary
  461. >
  462. <el-table-column label="序号" align="center" type="index" width="50px" />
  463. <el-table-column label="饲料名称" min-width="130px" align="center">
  464. <template slot-scope="scope">
  465. <span>{{ scope.row.fname }}</span>
  466. </template>
  467. </el-table-column>
  468. <el-table-column prop="fweight" sortable label="重量(KG)" />
  469. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.autosecond }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  475. <template slot-scope="scope">
  476. <span v-if="scope.row.islockcount == '0'">否</span>
  477. <span v-if="scope.row.islockcount == '1'">是</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column label="顺序" min-width="110px" align="center">
  481. <template slot-scope="scope">
  482. <span>{{ scope.row.sort }}</span>
  483. </template>
  484. </el-table-column>
  485. </el-table>
  486. </div>
  487. <h2>合成预混料</h2>
  488. <div class="table2" style="margin-bottom: 50px;">
  489. <el-table
  490. :key="detail.tableKey2"
  491. v-loading="detail.listLoading2"
  492. element-loading-text="给我一点时间"
  493. :data="detail.list2"
  494. border
  495. fit
  496. highlight-current-row
  497. style="width: 100%;"
  498. :row-style="rowStyle"
  499. :cell-style="cellStyle"
  500. class="elTable table-fixed"
  501. >
  502. <el-table-column label="配方名称" min-width="130px" align="center">
  503. <template slot-scope="scope">
  504. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="配方颜色" min-width="130px" align="center">
  508. <template slot-scope="scope">
  509. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="牲畜类别" min-width="130px" align="center">
  513. <template slot-scope="scope">
  514. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  515. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  516. </el-select>
  517. </template>
  518. </el-table-column>
  519. <el-table-column label="配方类型" min-width="110px" align="center">
  520. <template slot-scope="scope">
  521. <span>{{ scope.row.fttype }}</span>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="来源" min-width="110px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.source }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column label="备注" min-width="130px" align="center">
  530. <template slot-scope="scope">
  531. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  532. </template>
  533. </el-table-column>
  534. <el-table-column label="是否启用" min-width="130px" align="center">
  535. <template slot-scope="scope">
  536. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  537. </template>
  538. </el-table-column>
  539. </el-table>
  540. </div>
  541. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  542. <el-button class="cancel" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  543. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  544. </div>
  545. </div>
  546. </el-dialog>
  547. </div>
  548. </template>
  549. <script>
  550. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  551. import Sortable from 'sortablejs'
  552. import { MessageBox } from 'element-ui'
  553. import Cookies from 'js-cookie'
  554. export default {
  555. name: 'RecipeTemplate',
  556. data() {
  557. return {
  558. requestParams: [
  559. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  560. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  561. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  562. ],
  563. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  564. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  565. livestockTypeList: [], // 牲畜类别
  566. formulaTypeList: [], // 配方类型
  567. feedNameList: [], // 饲料名称
  568. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  569. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  570. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  571. arrowDown: true,
  572. arrowUp: false,
  573. table: {
  574. getdataListParm: {
  575. name: 'getFTList',
  576. page: 1,
  577. offset: 1,
  578. pagecount: 30,
  579. returntype: 'Map',
  580. parammaps: {
  581. pastureid: Cookies.get('pastureid'),
  582. tname: '',
  583. ccid: '',
  584. ccname: '',
  585. fttypeid: '',
  586. fttype: '',
  587. remark: '',
  588. enable: ''
  589. }
  590. },
  591. tableKey: 0,
  592. list: [],
  593. total: 0,
  594. listLoading: true,
  595. temp: {}
  596. },
  597. lockCount: {
  598. getdataListParm: {
  599. name: 'getSysoptEnable',
  600. page: 1,
  601. offset: 1,
  602. pagecount: 30,
  603. returntype: 'Map',
  604. parammaps: {
  605. pastureid: Cookies.get('pastureid'),
  606. inforname: 'isLockCount'
  607. }
  608. },
  609. isLockCount: false // 是否显示是否锁定牛头数比例
  610. },
  611. isDetail: false,
  612. arrowDown2: true,
  613. arrowUp2: false,
  614. table2: {
  615. getdataListParm: {
  616. name: 'getFTdetailList',
  617. page: 1,
  618. offset: 1,
  619. pagecount: 10,
  620. returntype: 'Map',
  621. parammaps: {
  622. pastureid: Cookies.get('pastureid'),
  623. fname: '',
  624. feedgroup: '',
  625. fweight: '',
  626. autosecondname: '',
  627. islockcount: '',
  628. sort: ''
  629. }
  630. },
  631. tableKey: 0,
  632. list: [],
  633. total: 0,
  634. listLoading: true,
  635. temp: {}
  636. },
  637. isDetailDialog: false,
  638. template: {
  639. dialogFormVisible: false,
  640. dialogStatus: '',
  641. table: {
  642. getdataListParm: {
  643. name: 'getFTListDate',
  644. page: 1,
  645. offset: 1,
  646. pagecount: 10,
  647. returntype: 'Map',
  648. parammaps: {
  649. pastureid: Cookies.get('pastureid'),
  650. tname: '',
  651. ccid: '',
  652. ccname: '',
  653. fttype: '',
  654. remark: '',
  655. enable: '',
  656. date: '',
  657. source: ''
  658. }
  659. },
  660. tableKey: 0,
  661. total: 0,
  662. listLoading: true,
  663. list: []
  664. },
  665. table2: {
  666. getdataListParm: {
  667. name: 'getFTdetailListDate',
  668. page: 1,
  669. offset: 1,
  670. pagecount: 10,
  671. returntype: 'Map',
  672. parammaps: {
  673. pastureid: Cookies.get('pastureid'),
  674. fname: '',
  675. fweight: '',
  676. islockcount: '',
  677. sort: '',
  678. feedgroup: '',
  679. autosecondname: ''
  680. }
  681. },
  682. tableKey: 0,
  683. total: 0,
  684. listLoading: true,
  685. list: []
  686. },
  687. // 历史日期
  688. getdataDateParm: {
  689. name: 'getFTMaxDate',
  690. page: 1,
  691. offset: 1,
  692. pagecount: 10,
  693. returntype: 'Map',
  694. parammaps: {
  695. pastureid: Cookies.get('pastureid')
  696. }
  697. }
  698. },
  699. detail: {
  700. dialogFormVisible: false,
  701. dialogStatus: '',
  702. tableKey: 0,
  703. total: 0,
  704. listLoading: true,
  705. list: [],
  706. tableKey2: 0,
  707. total2: 0,
  708. listLoading2: false,
  709. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  710. getdataListParm: {
  711. name: 'getFTDetailCompare',
  712. page: 1,
  713. offset: 1,
  714. pagecount: 10,
  715. returntype: 'Map',
  716. parammaps: {}
  717. },
  718. list3: [],
  719. disabled: false,
  720. getdataListParm2: {
  721. name: 'getFTCompare',
  722. page: 1,
  723. offset: 1,
  724. pagecount: 10,
  725. returntype: 'Map',
  726. parammaps: {}
  727. }
  728. },
  729. selectList: [],
  730. selectList2: [],
  731. textMap: {
  732. RecipeRecord: '配方记录',
  733. SyntheticPremix: '合成预混料'
  734. },
  735. requestParam: {},
  736. isokDisable: false,
  737. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  738. cellStyle: { padding: 0 + 'px' },
  739. dropState: false
  740. }
  741. },
  742. mounted() {
  743. document.addEventListener('click', (e) => {
  744. if (this.$refs.selectInput !== undefined) {
  745. if (!this.$refs.selectInput.contains(e.target)) {
  746. this.arrowDown = true
  747. this.arrowUp = false
  748. } else {
  749. this.arrowDown = false
  750. this.arrowUp = true
  751. }
  752. }
  753. if (this.$refs.selectInput2 !== undefined) {
  754. if (!this.$refs.selectInput2.contains(e.target)) {
  755. this.arrowDown2 = true
  756. this.arrowUp2 = false
  757. } else {
  758. this.arrowDown2 = false
  759. this.arrowUp2 = true
  760. }
  761. }
  762. })
  763. },
  764. created() {
  765. this.getList()
  766. this.getDownList()
  767. this.getIsLockCount()
  768. },
  769. methods: {
  770. handleHistory() {
  771. MessageBox.confirm('是否确认生成历史?', {
  772. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  773. }).then(() => {
  774. this.requestParam.name = 'creatFTdate'
  775. this.requestParam.parammaps = {}
  776. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  777. PostDataByName(this.requestParam).then(response => {
  778. console.log('生成历史保存发送参数', this.requestParam)
  779. if (response.msg !== 'fail') {
  780. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  781. } else {
  782. failproccess(response, this.$notify)
  783. }
  784. })
  785. })
  786. },
  787. getDownList() {
  788. GetDataByNames(this.requestParams).then(response => {
  789. this.livestockTypeList = response.data.getDictByName.list
  790. this.formulaTypeList = response.data.getDictByName2.list
  791. this.feedNameList = response.data.getFeedAndPre.list
  792. })
  793. },
  794. // -------------------模板-----------------------------
  795. getList() {
  796. this.table.listLoading = true
  797. GetDataByName(this.table.getdataListParm).then(response => {
  798. console.log('table数据', response.data.list)
  799. if (response.data.list !== null) {
  800. for (let i = 0; i < response.data.list.length; i++) {
  801. this.$set(response.data.list[i], 'Edit', false) // 编辑
  802. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  803. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  804. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  805. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  806. }
  807. this.table.list = response.data.list
  808. this.table.pageNum = response.data.pageNum
  809. this.table.pageSize = response.data.pageSize
  810. this.table.total = response.data.total
  811. } else {
  812. this.table.list = []
  813. }
  814. setTimeout(() => {
  815. this.table.listLoading = false
  816. }, 100)
  817. })
  818. },
  819. handleSearch() {
  820. console.log('点击了查询')
  821. this.table.getdataListParm.offset = 1
  822. this.getList()
  823. this.arrowDown = true
  824. this.arrowUp = false
  825. },
  826. handleRefresh() {
  827. console.log('点击了重置')
  828. this.table.getdataListParm.offset = 1
  829. this.table.getdataListParm.parammaps.ccid = ''
  830. this.table.getdataListParm.parammaps.ccname = ''
  831. this.table.getdataListParm.parammaps.fttype = ''
  832. this.table.getdataListParm.parammaps.tname = ''
  833. this.table.getdataListParm.parammaps.remark = ''
  834. this.table.getdataListParm.parammaps.enable = ''
  835. this.table.getdataListParm.parammaps.source = ''
  836. this.getList()
  837. },
  838. // 模板新增
  839. handleCreate() {
  840. console.log('点击了新增')
  841. // 编辑true/不可编辑false
  842. // 新增操true,编辑false,编辑保存false
  843. for (let i = 0; i < this.table.list.length; i++) {
  844. if (this.table.list[i].Edit === true) {
  845. console.log(123)
  846. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  847. return false
  848. }
  849. }
  850. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  851. console.log(this.table.list)
  852. },
  853. // 畜生类别
  854. changeLivestockType(item) {
  855. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  856. },
  857. // 配方类型
  858. changeFormulaType(item) {
  859. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  860. },
  861. createData(row) {
  862. console.log('点击了新增保存', row)
  863. this.table.temp.tname = row.tname
  864. this.table.temp.tcolor = row.tcolor
  865. this.table.temp.ccid = row.ccid
  866. this.table.temp.ccname = this.table.temp.ccname
  867. this.table.temp.fttype = this.table.temp.fttype
  868. this.table.temp.fttypeid = row.fttypeid
  869. this.table.temp.source = row.source
  870. this.table.temp.remark = row.remark
  871. this.table.temp.enable = row.enable
  872. this.table.temp.pastureid = Cookies.get('pastureid')
  873. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  874. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  875. return false
  876. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  877. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  878. return false
  879. } else if (this.table.temp.tname == '') {
  880. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  881. return false
  882. } else if (this.table.temp.ccid == '') {
  883. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  884. return false
  885. } else if (this.table.temp.fttypeid == '') {
  886. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  887. return false
  888. }
  889. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  890. if (pattern.test(this.table.temp.tname)) {
  891. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  892. return false
  893. }
  894. console.log(this.table.temp)
  895. this.isokDisable = true
  896. setTimeout(() => {
  897. this.isokDisable = false
  898. }, 1000)
  899. this.requestParam.name = 'insertFT'
  900. this.requestParam.parammaps = this.table.temp
  901. PostDataByName(this.requestParam).then(response => {
  902. console.log('新增保存发送参数', this.requestParam)
  903. if (response.msg !== 'fail') {
  904. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  905. this.getList()
  906. } else {
  907. failproccess(response, this.$notify)
  908. }
  909. })
  910. },
  911. createCancel(row) {
  912. console.log('点击了新增取消')
  913. for (let i = 0; i < this.table.list.length; i++) {
  914. if (row.myId === this.table.list[i].myId) {
  915. var listIndex = this.table.list.indexOf(this.table.list[i])
  916. }
  917. if (listIndex > -1) {
  918. this.table.list.splice(listIndex, 1)
  919. return
  920. }
  921. }
  922. },
  923. // 模板编辑
  924. handleUpdate(row) {
  925. for (let i = 0; i < this.table.list.length; i++) {
  926. if (this.table.list[i].Edit == true) {
  927. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  928. return false
  929. }
  930. }
  931. // 编辑true,不可编辑false
  932. row.Edit = true
  933. row.NoEdit = false
  934. // 新增false,编辑false,编辑保存true
  935. row.isCreate = false
  936. row.isUpdate = false
  937. row.isUpdateSave = true
  938. row.ccid = String(row.ccid)
  939. row.fttypeid = String(row.fttypeid)
  940. this.table.temp.ccname = row.ccname
  941. this.table.temp.fttype = row.fttype
  942. },
  943. updateData(row) {
  944. console.log('点击了编辑保存', row)
  945. this.table.temp.tname = row.tname
  946. this.table.temp.tcolor = row.tcolor
  947. this.table.temp.ccid = row.ccid
  948. this.table.temp.fttypeid = row.fttypeid
  949. this.table.temp.source = row.source
  950. this.table.temp.remark = row.remark
  951. this.table.temp.enable = row.enable
  952. this.table.temp.ccname = this.table.temp.ccname
  953. this.table.temp.fttype = this.table.temp.fttype
  954. this.table.temp.pastureid = row.pastureid
  955. this.table.temp.id = row.id
  956. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  957. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  958. return false
  959. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  960. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  961. return false
  962. } else if (this.table.temp.tname == '') {
  963. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  964. return false
  965. } else if (this.table.temp.ccid == '') {
  966. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  967. return false
  968. } else if (this.table.temp.fttypeid == '') {
  969. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  970. return false
  971. }
  972. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  973. if (pattern.test(this.table.temp.tname)) {
  974. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  975. return false
  976. }
  977. console.log(this.table.temp)
  978. this.isokDisable = true
  979. setTimeout(() => {
  980. this.isokDisable = false
  981. }, 1000)
  982. this.requestParam.name = 'updateFT'
  983. this.requestParam.parammaps = this.table.temp
  984. PostDataByName(this.requestParam).then(response => {
  985. console.log('新增保存发送参数', this.requestParam)
  986. if (response.msg !== 'fail') {
  987. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  988. this.getList()
  989. } else {
  990. failproccess(response, this.$notify)
  991. }
  992. })
  993. },
  994. updateCancel(row) {
  995. console.log('点击了编辑取消')
  996. // 编辑false,不可编辑true
  997. row.Edit = false
  998. row.NoEdit = true
  999. // 新增false,编辑true,编辑保存false
  1000. row.isCreate = false
  1001. row.isUpdate = true
  1002. row.isUpdateSave = false
  1003. this.getList()
  1004. },
  1005. // 删除
  1006. handleRowDelete(row) {
  1007. console.log('点击了行内删除')
  1008. MessageBox.confirm('是否确认删除此信息?', {
  1009. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1010. }).then(() => {
  1011. this.requestParam.common = { 'returnmap': '0' }
  1012. this.requestParam.data = []
  1013. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1014. pastureid: row.pastureid,
  1015. id: row.id
  1016. }}
  1017. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1018. pastureid: row.pastureid,
  1019. id: row.id
  1020. }}
  1021. ExecDataByConfig(this.requestParam).then(response => {
  1022. console.log('新增保存发送参数', this.requestParam)
  1023. if (response.msg === 'fail') {
  1024. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1025. } else {
  1026. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1027. this.getList()
  1028. }
  1029. })
  1030. }).catch(() => {
  1031. this.$message({ type: 'info', message: '已取消删除' })
  1032. })
  1033. },
  1034. handleSelectionChange(val) {
  1035. console.log('勾选数据', val)
  1036. this.selectList = val
  1037. },
  1038. handleDelete() {
  1039. console.log('点击了删除')
  1040. if (this.selectList.length == 0) {
  1041. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1042. } else {
  1043. MessageBox.confirm('是否确认删除此信息?', {
  1044. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1045. }).then(() => {
  1046. console.log(this.selectList)
  1047. this.requestParam.common = { 'returnmap': '0' }
  1048. this.requestParam.data = []
  1049. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1050. this.requestParam.data[0].children = []
  1051. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1052. id: '@insertSpotList.id',
  1053. pastureid: '@insertSpotList.pastureid'
  1054. }}
  1055. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1056. id: '@insertSpotList.id',
  1057. pastureid: '@insertSpotList.pastureid'
  1058. }}
  1059. ExecDataByConfig(this.requestParam).then(response => {
  1060. console.log('删除保存发送参数', this.requestParam)
  1061. if (response.msg === 'fail') {
  1062. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1063. } else {
  1064. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1065. this.getList()
  1066. }
  1067. })
  1068. })
  1069. }
  1070. },
  1071. // 复制
  1072. handleCopy() {
  1073. if (this.selectList.length == 0) {
  1074. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1075. } else {
  1076. MessageBox.confirm('是否确认复制此信息?', {
  1077. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1078. }).then(() => {
  1079. console.log(this.selectList)
  1080. this.requestParam.common = { 'returnmap': '0' }
  1081. this.requestParam.data = []
  1082. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1083. this.requestParam.data[0].children = []
  1084. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1085. ftid: '@insertSpotList.id',
  1086. pastureid: '@insertSpotList.pastureid'
  1087. }}
  1088. ExecDataByConfig(this.requestParam).then(response => {
  1089. console.log('复制保存发送参数', this.requestParam)
  1090. if (response.msg === 'fail') {
  1091. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1092. } else {
  1093. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1094. this.getList()
  1095. }
  1096. })
  1097. })
  1098. }
  1099. },
  1100. // 配方记录
  1101. handleRecipeRecord() {
  1102. console.log('点击了配方记录')
  1103. this.template.dialogStatus = 'RecipeRecord'
  1104. this.template.dialogFormVisible = true
  1105. this.template.table.getdataListParm.parammaps.ccname = ''
  1106. this.template.table.getdataListParm.parammaps.fttype = ''
  1107. this.template.table.getdataListParm.parammaps.enable = ''
  1108. this.template.table.getdataListParm.parammaps.tname = ''
  1109. this.template.table.getdataListParm.parammaps.remark = ''
  1110. this.template.table.getdataListParm.parammaps.source = ''
  1111. this.template.table.getdataListParm.offset = 1
  1112. this.getDateList()
  1113. this.isDetailDialog = false
  1114. },
  1115. // 历史时间
  1116. getDateList() {
  1117. GetDataByName(this.template.getdataDateParm).then(response => {
  1118. console.log('table数据', response.data.list)
  1119. if (response.data.list !== null) {
  1120. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1121. this.getTemplateDialogList()
  1122. } else {
  1123. this.template.table.getdataListParm.parammaps.date = ''
  1124. }
  1125. })
  1126. },
  1127. // 配方记录-模板
  1128. getTemplateDialogList() {
  1129. this.template.table.listLoading = true
  1130. GetDataByName(this.template.table.getdataListParm).then(response => {
  1131. console.log('table数据', response.data.list)
  1132. if (response.data.list !== null) {
  1133. this.template.table.list = response.data.list
  1134. this.template.table.pageNum = response.data.pageNum
  1135. this.template.table.pageSize = response.data.pageSize
  1136. this.template.table.total = response.data.total
  1137. } else {
  1138. this.template.table.list = []
  1139. }
  1140. setTimeout(() => {
  1141. this.template.table.listLoading = false
  1142. }, 100)
  1143. })
  1144. },
  1145. handleDialogSearch() {
  1146. this.template.table.getdataListParm.offset = 1
  1147. this.getTemplateDialogList()
  1148. this.arrowDown = true
  1149. this.arrowUp = false
  1150. },
  1151. handleDialogRefresh() {
  1152. this.template.table.getdataListParm.parammaps.ccname = ''
  1153. this.template.table.getdataListParm.parammaps.fttype = ''
  1154. this.template.table.getdataListParm.parammaps.enable = ''
  1155. this.template.table.getdataListParm.parammaps.tname = ''
  1156. this.template.table.getdataListParm.parammaps.remark = ''
  1157. this.template.table.getdataListParm.parammaps.source = ''
  1158. this.template.table.getdataListParm.offset = 1
  1159. this.getTemplateDialogList()
  1160. },
  1161. // 配方记录-模板行点击
  1162. tableRowClickDialog(row, column, event) {
  1163. console.log('配方记录-模板行点击')
  1164. this.isDetailDialog = true
  1165. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1166. this.getDialogList()
  1167. this.getDownList()
  1168. },
  1169. getDialogList() {
  1170. this.template.table2.listLoading = true
  1171. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1172. console.log('table数据', response.data.list)
  1173. if (response.data.list !== null) {
  1174. this.template.table2.list = response.data.list
  1175. this.template.table2.pageNum = response.data.pageNum
  1176. this.template.table2.pageSize = response.data.pageSize
  1177. this.template.table2.total = response.data.total
  1178. } else {
  1179. this.template.table2.list = []
  1180. }
  1181. setTimeout(() => {
  1182. this.template.table2.listLoading = false
  1183. }, 100)
  1184. })
  1185. },
  1186. handleDialogSearch2() {
  1187. console.log('点击了查询')
  1188. this.arrowDown2 = true
  1189. this.arrowUp2 = false
  1190. this.template.table2.getdataListParm.offset = 1
  1191. this.getDialogList2()
  1192. },
  1193. handleDialogRefresh2() {
  1194. console.log('点击了重置')
  1195. this.template.table2.getdataListParm.parammaps.fname = ''
  1196. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1197. this.template.table2.getdataListParm.parammaps.fweight = ''
  1198. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1199. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1200. this.template.table2.getdataListParm.parammaps.sort = ''
  1201. this.template.table2.getdataListParm.offset = 1
  1202. this.getDialogList2()
  1203. },
  1204. getDialogList2() {
  1205. this.template.table2.listLoading = true
  1206. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1207. console.log('table数据', response.data.list)
  1208. if (response.data.list !== null) {
  1209. this.template.table2.list = response.data.list
  1210. this.template.table2.pageNum = response.data.pageNum
  1211. this.template.table2.pageSize = response.data.pageSize
  1212. this.template.table2.total = response.data.total
  1213. } else {
  1214. this.template.table2.list = []
  1215. }
  1216. this.$nextTick(function() {
  1217. window.scrollTo({
  1218. 'top': this.$refs.templateDialog.clientHeight
  1219. })
  1220. })
  1221. setTimeout(() => {
  1222. this.template.table2.listLoading = false
  1223. }, 100)
  1224. })
  1225. },
  1226. handleImport() {
  1227. console.log('点击了导入')
  1228. },
  1229. handleExport() {
  1230. console.log('点击了导出')
  1231. },
  1232. changeDate() {
  1233. this.getTemplateDialogList()
  1234. },
  1235. // 应用
  1236. handleApplication() {
  1237. console.log('点击了应用')
  1238. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1239. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1240. }).then(() => {
  1241. this.requestParam.name = 'applyFTdate'
  1242. this.requestParam.parammaps = {}
  1243. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1244. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1245. PostDataByName(this.requestParam).then(response => {
  1246. if (response.msg === 'fail') {
  1247. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1248. } else {
  1249. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1250. this.getTemplateDialogList()
  1251. this.getList()
  1252. }
  1253. })
  1254. }).catch(() => {
  1255. this.$message({ type: 'info', message: '已取消应用' })
  1256. })
  1257. },
  1258. // 模板行点击
  1259. tableRowClick(row, column, event) {
  1260. console.log(row, column, event)
  1261. for (let i = 0; i < this.table.list.length; i++) {
  1262. if (this.table.list[i].Edit == true) {
  1263. return false
  1264. }
  1265. }
  1266. if (column.label !== '操作') {
  1267. this.isDetail = true // 点击行显示详情
  1268. this.table2.getdataListParm.parammaps.ftid = row.id
  1269. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1270. this.getList2()
  1271. this.getDownList()
  1272. }
  1273. },
  1274. // -------------------详情-----------------------------
  1275. // 获取是否显示是否锁定牛头数
  1276. getIsLockCount() {
  1277. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1278. console.log(response.data.list)
  1279. if (response.data.list[0].inforvalue == 0) {
  1280. this.lockCount.isLockCount = false
  1281. } else {
  1282. this.lockCount.isLockCount = true
  1283. }
  1284. })
  1285. },
  1286. // 详情
  1287. getList2() {
  1288. this.table2.listLoading = true
  1289. GetDataByName(this.table2.getdataListParm).then(response => {
  1290. console.log('table数据', response.data.list)
  1291. if (response.data.list !== null) {
  1292. for (let i = 0; i < response.data.list.length; i++) {
  1293. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1294. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1295. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1296. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1297. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1298. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1299. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1300. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1301. }
  1302. this.table2.list = response.data.list
  1303. this.table2.pageNum = response.data.pageNum
  1304. this.table2.pageSize = response.data.pageSize
  1305. this.table2.total = response.data.total
  1306. this.rowDrop()
  1307. } else {
  1308. this.table2.list = []
  1309. }
  1310. this.$nextTick(function() {
  1311. console.log(this.$refs)
  1312. console.log(this.$refs.template.clientHeight)
  1313. window.scrollTo({
  1314. 'top': this.$refs.template.clientHeight
  1315. })
  1316. })
  1317. setTimeout(() => {
  1318. this.table2.listLoading = false
  1319. }, 100)
  1320. })
  1321. },
  1322. // 行拖拽
  1323. rowDrop() {
  1324. console.log(1111)
  1325. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1326. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1327. // this.sorTable()
  1328. const that = this
  1329. // Sortable.create(tbody, {
  1330. var sortable = Sortable.create(tbody, {
  1331. // sort: false,
  1332. disabled: that.dropState,
  1333. onChoose({ newIndex, oldIndex }) {
  1334. console.log(that.dropState, 'that.dropState========')
  1335. if (that.dropState == true) {
  1336. // return false
  1337. sortable.destroy()
  1338. }
  1339. },
  1340. onEnd({ newIndex, oldIndex }) {
  1341. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1342. that.table2.list.splice(newIndex, 0, currRow)
  1343. console.log('索引', newIndex)
  1344. console.log('拖动数据', currRow)
  1345. console.log('上', that.table2.list[newIndex - 1])
  1346. console.log('下', that.table2.list[newIndex + 1])
  1347. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1348. for (let i = 0; i < that.table2.list.length; i++) {
  1349. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1350. }
  1351. currRow.sort = 0
  1352. currRow.feedgroup = currRow.fname
  1353. console.log('拖动至最上方无值')
  1354. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1355. currRow.sort = that.table2.list[newIndex - 1].sort
  1356. console.log('拖动值顺序等于上值顺序')
  1357. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1358. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1359. currRow.feedgroup = currRow.fname
  1360. console.log('拖动至最下方无值')
  1361. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1362. currRow.sort == that.table2.list[newIndex + 1].sort
  1363. console.log('拖动值顺序等于下值顺序')
  1364. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1365. currRow.sort = that.table2.list[newIndex - 1].sort
  1366. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1367. console.log('拖动至上下顺序一致')
  1368. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1369. console.log('上下')
  1370. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1371. console.log(newIndex)
  1372. for (let i = newIndex; i < that.table2.list.length; i++) {
  1373. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1374. }
  1375. }
  1376. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1377. currRow.feedgroup = currRow.fname
  1378. console.log(that.table2.list[newIndex + 1].sort)
  1379. }
  1380. that.requestParam = {}
  1381. that.requestParam.common = { 'returnmap': '0' }
  1382. that.requestParam.data = []
  1383. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1384. that.requestParam.data[0].children = []
  1385. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1386. id: '@insertSpotList.id',
  1387. pastureid: '@insertSpotList.pastureid',
  1388. sort: '@insertSpotList.sort',
  1389. feedgroup: '@insertSpotList.feedgroup'
  1390. }}
  1391. ExecDataByConfig(that.requestParam).then(response => {
  1392. console.log('顺序切换保存发送参数', that.requestParam)
  1393. if (response.msg === 'fail') {
  1394. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1395. } else {
  1396. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1397. that.getList2()
  1398. }
  1399. })
  1400. }
  1401. })
  1402. console.log(sortable.option('disabled'))
  1403. },
  1404. handleSearch2() {
  1405. console.log('点击了查询')
  1406. this.arrowDown2 = true
  1407. this.arrowUp2 = false
  1408. this.table2.getdataListParm.offset = 1
  1409. this.getList2()
  1410. },
  1411. handleRefresh2() {
  1412. console.log('点击了重置')
  1413. this.table2.getdataListParm.parammaps.fname = ''
  1414. this.table2.getdataListParm.parammaps.feedgroup = ''
  1415. this.table2.getdataListParm.parammaps.fweight = ''
  1416. this.table2.getdataListParm.parammaps.autosecondname = ''
  1417. this.table2.getdataListParm.parammaps.islockcount = '0'
  1418. this.table2.getdataListParm.parammaps.sort = ''
  1419. this.table2.getdataListParm.offset = 1
  1420. this.getList2()
  1421. },
  1422. // 详情新增
  1423. handleCreate2() {
  1424. console.log('点击了详情新增', this.table2.list)
  1425. // 编辑true/不可编辑false
  1426. // 新增操true,编辑false,编辑保存false
  1427. console.log(11)
  1428. for (let i = 0; i < this.table2.list.length; i++) {
  1429. if (this.table2.list[i].Edit === true) {
  1430. console.log(123)
  1431. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1432. return false
  1433. }
  1434. }
  1435. console.log(this.table2.list)
  1436. if (this.table2.list.length == 0) {
  1437. var mysort = 0
  1438. } else {
  1439. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1440. }
  1441. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1442. console.log(this.table2.list)
  1443. },
  1444. changeFname(item, row) {
  1445. console.log(item, row)
  1446. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1447. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1448. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1449. this.table2.temp.preftid = '0'
  1450. } else {
  1451. this.table2.temp.preftid = item
  1452. }
  1453. if (row.sort == '') {
  1454. row.feedgroup = this.table2.temp.fname
  1455. } else {
  1456. if (row.isCreate == true) { // 新增状态下
  1457. for (let i = 1; i < this.table2.list.length; i++) {
  1458. if (this.table2.list[i].sort == row.sort) {
  1459. console.log(this.table2.list[i])
  1460. row.feedgroup = this.table2.list[i].feedgroup
  1461. break
  1462. } else {
  1463. row.feedgroup = this.table2.temp.fname
  1464. }
  1465. }
  1466. } else if (row.isUpdateSave == true) { // 编辑状态下
  1467. var Arr = []
  1468. for (let i = 0; i < this.table2.list.length; i++) {
  1469. Arr.push(this.table2.list[i].sort)
  1470. }
  1471. var Count = 0
  1472. for (let i = 0; i < Arr.length; i++) {
  1473. if (Arr[i] == row.sort) {
  1474. Count++
  1475. }
  1476. }
  1477. for (let i = 0; i < this.table2.list.length; i++) {
  1478. if (Count > 1) {
  1479. row.feedgroup = this.table2.list[i].feedgroup
  1480. console.log(111, this.table2.list[i].feedgroup)
  1481. break
  1482. } else if (Count == 1) {
  1483. row.feedgroup = this.table2.temp.fname
  1484. console.log(222, this.table2.temp.fname)
  1485. }
  1486. }
  1487. }
  1488. }
  1489. },
  1490. blurSort(row) {
  1491. if (row.isCreate == true) {
  1492. if (row.sort !== '') {
  1493. for (let i = 1; i < this.table2.list.length; i++) {
  1494. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1495. row.feedgroup = this.table2.list[i].feedgroup
  1496. return false
  1497. } else {
  1498. row.feedgroup = row.fname
  1499. }
  1500. }
  1501. } else {
  1502. row.feedgroup = row.fname
  1503. }
  1504. } else if (row.isUpdateSave == true) {
  1505. if (row.sort !== '') {
  1506. for (let i = 0; i < this.table2.list.length; i++) {
  1507. if (this.table2.list[i].sort == row.sort) {
  1508. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1509. if (this.table2.list[i].id !== row.id) {
  1510. row.isGroupDisabled = true
  1511. row.feedgroup = this.table2.list[i].feedgroup
  1512. break
  1513. }
  1514. } else {
  1515. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1516. row.isGroupDisabled = true
  1517. row.feedgroup = row.fname
  1518. }
  1519. }
  1520. } else {
  1521. row.feedgroup = row.fname
  1522. }
  1523. }
  1524. },
  1525. createData2(row) {
  1526. console.log('点击了详情新增保存', row)
  1527. this.table2.temp.pastureid = Cookies.get('pastureid')
  1528. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1529. this.table2.temp.fid = row.fid
  1530. this.table2.temp.fname = this.table2.temp.fname
  1531. this.table2.temp.fweight = row.fweight
  1532. this.table2.temp.islockcount = row.islockcount
  1533. this.table2.temp.sort = row.sort
  1534. this.table2.temp.feedgroup = row.feedgroup
  1535. this.table2.temp.preftid = this.table2.temp.preftid
  1536. this.table2.temp.autosecond = row.autosecond
  1537. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1538. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1539. return false
  1540. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1541. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1542. return false
  1543. } else if (this.table2.temp.fid == '') {
  1544. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1545. return false
  1546. } else if (this.table2.temp.fweight == '') {
  1547. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1548. return false
  1549. } else if (this.table2.temp.autosecond == '') {
  1550. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1551. return false
  1552. }
  1553. if (this.table2.temp.sort !== '') {
  1554. this.table2.temp.sort = this.table2.temp.sort
  1555. } else {
  1556. console.log(this.table2.list.length)
  1557. if (this.table2.list.length == 1) {
  1558. this.table2.temp.sort = 0
  1559. } else {
  1560. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1561. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1562. }
  1563. }
  1564. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1565. if (parseInt(this.table2.temp.preftid) > 0) {
  1566. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1567. return false
  1568. }
  1569. }
  1570. // 校验顺序是否>=0
  1571. var ruleSort = /^\d+$/
  1572. if (!ruleSort.test(this.table2.temp.sort)) {
  1573. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1574. return false
  1575. }
  1576. // 检验重量>0
  1577. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1578. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1579. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1580. return false
  1581. }
  1582. this.isokDisable = true
  1583. setTimeout(() => {
  1584. this.isokDisable = false
  1585. }, 1000)
  1586. this.requestParam.common = { 'returnmap': '0' }
  1587. this.requestParam.data = []
  1588. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1589. pastureid: this.table2.temp.pastureid,
  1590. ftid: this.table2.getdataListParm.parammaps.ftid,
  1591. fid: row.fid,
  1592. fname: this.table2.temp.fname,
  1593. fweight: row.fweight,
  1594. islockcount: row.islockcount,
  1595. sort: row.sort,
  1596. feedgroup: row.feedgroup,
  1597. preftid: this.table2.temp.preftid,
  1598. autosecond: row.autosecond
  1599. }}
  1600. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1601. pastureid: this.table2.temp.pastureid,
  1602. ftid: this.table2.getdataListParm.parammaps.ftid,
  1603. type: this.table2.getdataListParm.parammaps.fttypeid
  1604. }}
  1605. ExecDataByConfig(this.requestParam).then(response => {
  1606. console.log('新增保存发送参数', this.requestParam)
  1607. if (response.msg !== 'fail') {
  1608. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1609. this.getList2()
  1610. } else {
  1611. failproccess(response, this.$notify)
  1612. }
  1613. })
  1614. },
  1615. createCancel2(row) {
  1616. console.log('点击了详情新增取消')
  1617. for (let i = 0; i < this.table2.list.length; i++) {
  1618. if (row.myId === this.table2.list[i].myId) {
  1619. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1620. }
  1621. if (listIndex > -1) {
  1622. this.table2.list.splice(listIndex, 1)
  1623. return
  1624. }
  1625. }
  1626. this.getDialogList()
  1627. },
  1628. // 详情编辑
  1629. handleUpdate2(row) {
  1630. console.log('详情编辑', row)
  1631. this.dropState = true
  1632. row.isGroupDisabled = false
  1633. row.islockcount = String(row.islockcount)
  1634. row.fid = String(row.fid)
  1635. row.autosecond = String(row.autosecond)
  1636. this.table2.temp.fname = row.fname
  1637. this.table2.temp.preftid = row.preftid
  1638. const rowArr = []
  1639. for (let i = 0; i < this.table2.list.length; i++) {
  1640. if (this.table2.list[i].Edit == true) {
  1641. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1642. return false
  1643. }
  1644. rowArr.push(this.table2.list[i].sort)
  1645. }
  1646. var count = 0
  1647. for (let i = 0; i < rowArr.length; i++) {
  1648. if (rowArr[i] == row.sort) {
  1649. count++
  1650. }
  1651. }
  1652. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1653. if (count == 1) {
  1654. // 饲料组编辑false,不可编辑true
  1655. row.groupEdit = false
  1656. row.groupNoEdit = true
  1657. // 编辑true,不可编辑false
  1658. row.Edit = true
  1659. row.NoEdit = false
  1660. // 新增false,编辑false,编辑保存true
  1661. row.isCreate = false
  1662. row.isUpdate = false
  1663. row.isUpdateSave = true
  1664. } else if (count > 1) {
  1665. // 饲料组编辑true,不可编辑false
  1666. row.groupEdit = true
  1667. row.groupNoEdit = false
  1668. console.log(222)
  1669. // 编辑true,不可编辑false
  1670. row.Edit = true
  1671. row.NoEdit = false
  1672. // 新增false,编辑false,编辑保存true
  1673. row.isCreate = false
  1674. row.isUpdate = false
  1675. row.isUpdateSave = true
  1676. return false
  1677. }
  1678. },
  1679. updateData2(row) {
  1680. console.log('点击了详情编辑保存111', row)
  1681. this.isokDisable = true
  1682. setTimeout(() => {
  1683. this.isokDisable = false
  1684. }, 1000)
  1685. this.table2.temp.pastureid = row.pastureid
  1686. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1687. this.table2.temp.fid = row.fid
  1688. this.table2.temp.fname = this.table2.temp.fname
  1689. this.table2.temp.fweight = row.fweight
  1690. this.table2.temp.islockcount = row.islockcount
  1691. this.table2.temp.sort = row.sort
  1692. this.table2.temp.feedgroup = row.feedgroup
  1693. this.table2.temp.preftid = this.table2.temp.preftid
  1694. this.table2.temp.autosecond = row.autosecond
  1695. this.table2.temp.id = row.id
  1696. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1697. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1698. return false
  1699. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1700. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1701. return false
  1702. } else if (this.table2.temp.fid == '') {
  1703. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1704. return false
  1705. } else if (this.table2.temp.fweight == '') {
  1706. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1707. return false
  1708. } else if (this.table2.temp.autosecond == '') {
  1709. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1710. return false
  1711. }
  1712. if (this.table2.temp.sort !== '') {
  1713. this.table2.temp.sort = this.table2.temp.sort
  1714. } else {
  1715. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1716. }
  1717. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1718. if (parseInt(this.table2.temp.preftid) > 0) {
  1719. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1720. return false
  1721. }
  1722. }
  1723. // 校验顺序是否>=0
  1724. var ruleSort = /^\d+$/
  1725. if (!ruleSort.test(this.table2.temp.sort)) {
  1726. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1727. return false
  1728. }
  1729. // 检验重量>0
  1730. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1731. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1732. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1733. return false
  1734. }
  1735. this.requestParam.common = { 'returnmap': '0' }
  1736. this.requestParam.data = []
  1737. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1738. pastureid: row.pastureid,
  1739. ftid: this.table2.getdataListParm.parammaps.ftid,
  1740. fid: row.fid,
  1741. fname: this.table2.temp.fname,
  1742. fweight: row.fweight,
  1743. islockcount: row.islockcount,
  1744. sort: row.sort,
  1745. feedgroup: row.feedgroup,
  1746. preftid: this.table2.temp.preftid,
  1747. autosecond: row.autosecond,
  1748. id: row.id
  1749. }}
  1750. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1751. pastureid: row.pastureid,
  1752. ftid: this.table2.getdataListParm.parammaps.ftid,
  1753. type: this.table2.getdataListParm.parammaps.fttypeid
  1754. }}
  1755. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1756. pastureid: row.pastureid,
  1757. ftid: this.table2.getdataListParm.parammaps.ftid,
  1758. sort: row.sort,
  1759. feedgroup: row.feedgroup
  1760. }}
  1761. ExecDataByConfig(this.requestParam).then(response => {
  1762. console.log('新增保存发送参数', this.requestParam)
  1763. if (response.msg !== 'fail') {
  1764. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1765. this.getList2()
  1766. this.dropState = false
  1767. } else {
  1768. failproccess(response, this.$notify)
  1769. }
  1770. })
  1771. },
  1772. updateCancel2(row) {
  1773. console.log('点击了详情编辑取消')
  1774. // 饲料组编辑false,不可编辑true
  1775. row.groupEdit = false
  1776. row.groupNoEdit = true
  1777. // 编辑false,不可编辑true
  1778. row.Edit = false
  1779. row.NoEdit = true
  1780. // 新增false,编辑true,编辑保存false
  1781. row.isCreate = false
  1782. row.isUpdate = true
  1783. row.isUpdateSave = false
  1784. this.getList2()
  1785. this.dropState = false
  1786. },
  1787. // 详情删除
  1788. handleRowDelete2(row) {
  1789. console.log('点击了行内删除')
  1790. MessageBox.confirm('是否确认删除此信息?', {
  1791. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1792. }).then(() => {
  1793. this.requestParam.common = { 'returnmap': '0' }
  1794. this.requestParam.data = []
  1795. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1796. pastureid: row.pastureid,
  1797. id: row.id
  1798. }}
  1799. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1800. pastureid: row.pastureid,
  1801. ftid: this.table2.getdataListParm.parammaps.ftid,
  1802. type: this.table2.getdataListParm.parammaps.fttypeid
  1803. }}
  1804. ExecDataByConfig(this.requestParam).then(response => {
  1805. console.log('新增保存发送参数', this.requestParam)
  1806. if (response.msg === 'fail') {
  1807. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1808. } else {
  1809. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1810. this.getList2()
  1811. }
  1812. })
  1813. }).catch(() => {
  1814. this.$message({ type: 'info', message: '已取消删除' })
  1815. })
  1816. },
  1817. handleSelectionChange2(val) {
  1818. console.log('勾选数据', val)
  1819. this.selectList2 = val
  1820. },
  1821. handleDelete2() {
  1822. console.log('点击了删除')
  1823. if (this.selectList2.length == 0) {
  1824. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1825. } else {
  1826. MessageBox.confirm('是否确认删除此信息?', {
  1827. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1828. }).then(() => {
  1829. console.log(this.selectList)
  1830. this.requestParam.common = { 'returnmap': '0' }
  1831. this.requestParam.data = []
  1832. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1833. this.requestParam.data[0].children = []
  1834. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1835. id: '@insertSpotList.id',
  1836. pastureid: '@insertSpotList.pastureid'
  1837. }}
  1838. ExecDataByConfig(this.requestParam).then(response => {
  1839. console.log('删除保存发送参数', this.requestParam)
  1840. if (response.msg === 'fail') {
  1841. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1842. } else {
  1843. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1844. this.getList2()
  1845. }
  1846. })
  1847. })
  1848. }
  1849. },
  1850. // 拆分预混料
  1851. handleSplitPremix(row) {
  1852. console.log('点击了拆分预混料')
  1853. MessageBox.confirm('是否确认拆分当前预混料?', {
  1854. confirmButtonText: '确认',
  1855. cancelButtonText: '取消',
  1856. type: 'warning'
  1857. }).then(() => {
  1858. this.requestParam.name = 'splitFTpre'
  1859. this.requestParam.parammaps = {}
  1860. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1861. this.requestParam.parammaps.preftid = row.preftid
  1862. this.requestParam.parammaps.ftdid = row.id
  1863. this.requestParam.parammaps.pastureid = row.pastureid
  1864. this.requestParam.parammaps.feedgroup = row.feedgroup
  1865. this.requestParam.parammaps.sort = row.sort
  1866. this.requestParam.parammaps.fweight = row.fweight
  1867. PostDataByName(this.requestParam).then(response => {
  1868. if (response.msg === 'fail') {
  1869. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1870. } else {
  1871. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1872. this.getList2()
  1873. }
  1874. })
  1875. }).catch(() => {
  1876. this.$message({
  1877. type: 'info',
  1878. message: '已取消删除'
  1879. })
  1880. })
  1881. },
  1882. // 合成预混料
  1883. handleSyntheticPremix() {
  1884. console.log('点击了合成预混料', this.selectList2)
  1885. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1886. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1887. return false
  1888. } else {
  1889. if (this.selectList2.length > 1) {
  1890. for (let i = 0; i < this.selectList2.length; i++) {
  1891. if (parseInt(this.selectList2[i].preftid) > 0) {
  1892. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1893. return false
  1894. }
  1895. }
  1896. if (this.selectList2[0].splitftpreid !== undefined) {
  1897. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1898. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1899. GetDataByName(this.detail.getdataListParm).then(response => {
  1900. if (response.data.list !== null) { // 不为空时得到比对数据
  1901. this.detail.list3 = response.data.list
  1902. const sortList = [] // 声明排序数组
  1903. var fweightSum = 0 // 总重量
  1904. for (let i = 0; i < this.selectList2.length; i++) {
  1905. const obj = {}
  1906. obj.fid = this.selectList2[i].fid
  1907. obj.fweight = this.selectList2[i].fweight
  1908. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1909. sortList.push(obj)
  1910. }
  1911. // 排序
  1912. sortList.sort(function(a, b) {
  1913. return a.fid.localeCompare(b.fid)
  1914. })
  1915. var a = 0
  1916. if (this.detail.list3.length == sortList.length) {
  1917. for (let i = 0; i < this.detail.list3.length; i++) {
  1918. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  1919. a++
  1920. }
  1921. }
  1922. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1923. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1924. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1925. GetDataByName(this.detail.getdataListParm2).then(response => {
  1926. if (response.data.list !== null) {
  1927. this.detail.dialogStatus = 'SyntheticPremix'
  1928. this.detail.dialogFormVisible = true
  1929. this.detail.list = this.selectList2
  1930. this.detail.list2 = response.data.list
  1931. this.detail.disabled = true
  1932. setTimeout(() => {
  1933. this.detail.listLoading = false
  1934. }, 100)
  1935. } else {
  1936. this.detail.list2 = []
  1937. }
  1938. })
  1939. } else {
  1940. this.detail.dialogStatus = 'SyntheticPremix'
  1941. this.detail.dialogFormVisible = true
  1942. this.detail.list = this.selectList2
  1943. this.detail.disabled = false
  1944. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1945. setTimeout(() => {
  1946. this.detail.listLoading = false
  1947. }, 100)
  1948. }
  1949. } else {
  1950. this.detail.dialogStatus = 'SyntheticPremix'
  1951. this.detail.dialogFormVisible = true
  1952. this.detail.list = this.selectList2
  1953. this.detail.disabled = false
  1954. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1955. setTimeout(() => {
  1956. this.detail.listLoading = false
  1957. }, 100)
  1958. }
  1959. } else {
  1960. this.detail.list3 = []
  1961. this.detail.dialogStatus = 'SyntheticPremix'
  1962. this.detail.dialogFormVisible = true
  1963. this.detail.list = this.selectList2
  1964. this.detail.disabled = false
  1965. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1966. setTimeout(() => {
  1967. this.detail.listLoading = false
  1968. }, 100)
  1969. }
  1970. })
  1971. } else {
  1972. this.detail.dialogStatus = 'SyntheticPremix'
  1973. this.detail.dialogFormVisible = true
  1974. this.detail.list = this.selectList2
  1975. this.detail.disabled = false
  1976. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1977. setTimeout(() => {
  1978. this.detail.listLoading = false
  1979. }, 100)
  1980. }
  1981. } else {
  1982. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1983. return false
  1984. }
  1985. }
  1986. },
  1987. // 畜生类别
  1988. changeLivestockType2(item) {
  1989. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1990. },
  1991. syntheticPremixData() {
  1992. console.log('点击了合成预混料确认')
  1993. if (this.detail.disabled == true) { // 原预混料
  1994. let sumFweight = 0
  1995. for (let i = 0; i < this.detail.list.length; i++) {
  1996. sumFweight += parseFloat(this.detail.list[i].fweight)
  1997. }
  1998. sumFweight = sumFweight.toFixed(2)
  1999. this.isokDisable = true
  2000. setTimeout(() => {
  2001. this.isokDisable = false
  2002. }, 1000)
  2003. this.requestParam.common = { 'returnmap': '0' }
  2004. this.requestParam.data = []
  2005. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2006. this.requestParam.data[0].children = []
  2007. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2008. pastureid: '@insertSpotList.pastureid',
  2009. id: '@insertSpotList.id'
  2010. }}
  2011. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2012. this.requestParam.data[1].children = []
  2013. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2014. pastureid: Cookies.get('pastureid'),
  2015. ftid: this.table2.getdataListParm.parammaps.ftid,
  2016. fid: this.detail.list2[0].id,
  2017. fname: '@insertSpotList2.tname',
  2018. fweight: sumFweight,
  2019. islockcount: '0',
  2020. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2021. feedgroup: '@insertSpotList2.tname',
  2022. preftid: this.detail.list2[0].id,
  2023. autosecond: this.detail.list[0].autosecond
  2024. }}
  2025. ExecDataByConfig(this.requestParam).then(response => {
  2026. console.log('合成预混料保存发送参数', this.requestParam)
  2027. if (response.msg === 'fail') {
  2028. const tname = new RegExp("key 'tname'")
  2029. if (tname.test(response.data)) {
  2030. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2031. } else {
  2032. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2033. }
  2034. } else {
  2035. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2036. this.detail.dialogFormVisible = false
  2037. this.getList()
  2038. this.getList2()
  2039. this.getDownList()
  2040. }
  2041. })
  2042. } else { // 现生成预混料
  2043. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2044. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2045. return false
  2046. } else if (this.detail.list2[0].tname == '') {
  2047. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2048. return false
  2049. } else if (this.detail.list2[0].ccid == '') {
  2050. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2051. return false
  2052. }
  2053. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2054. if (pattern.test(this.detail.list2[0].tname)) {
  2055. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2056. return false
  2057. }
  2058. let sumFweight = 0
  2059. for (let i = 0; i < this.detail.list.length; i++) {
  2060. sumFweight += parseFloat(this.detail.list[i].fweight)
  2061. }
  2062. sumFweight = sumFweight.toFixed(2)
  2063. console.log(sumFweight)
  2064. this.isokDisable = true
  2065. setTimeout(() => {
  2066. this.isokDisable = false
  2067. }, 1000)
  2068. this.requestParam.common = { 'returnmap': '0' }
  2069. this.requestParam.data = []
  2070. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2071. pastureid: Cookies.get('pastureid'),
  2072. tcode: this.detail.list2[0].tcode,
  2073. tname: this.detail.list2[0].tname,
  2074. tcolor: this.detail.list2[0].tcolor,
  2075. ccid: this.detail.list2[0].ccid,
  2076. ccname: this.detail.list2[0].ccname,
  2077. fttype: this.detail.list2[0].fttype,
  2078. fttypeid: this.detail.list2[0].fttypeid,
  2079. source: this.detail.list2[0].source,
  2080. remark: this.detail.list2[0].remark,
  2081. enable: this.detail.list2[0].enable
  2082. }}
  2083. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2084. this.requestParam.data[1].children = []
  2085. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2086. pastureid: '@insertSpotList.pastureid',
  2087. ftid: '@insertFT.LastInsertId',
  2088. fid: '@insertSpotList.fid',
  2089. fname: '@insertSpotList.fname',
  2090. fweight: '@insertSpotList.fweight',
  2091. islockcount: '@insertSpotList.islockcount',
  2092. sort: '@insertSpotList.sort',
  2093. feedgroup: '@insertSpotList.feedgroup',
  2094. preftid: '@insertSpotList.preftid',
  2095. autosecond: '@insertSpotList.autosecond'
  2096. }}
  2097. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2098. pastureid: '@insertSpotList.pastureid',
  2099. id: '@insertSpotList.id'
  2100. }}
  2101. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2102. this.requestParam.data[2].children = []
  2103. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2104. pastureid: Cookies.get('pastureid'),
  2105. ftid: this.table2.getdataListParm.parammaps.ftid,
  2106. fid: '@insertFT.LastInsertId',
  2107. fname: '@insertSpotList2.tname',
  2108. fweight: sumFweight,
  2109. islockcount: '0',
  2110. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2111. feedgroup: '@insertSpotList2.tname',
  2112. preftid: '@insertFT.LastInsertId',
  2113. autosecond: this.detail.list[0].autosecond
  2114. }}
  2115. ExecDataByConfig(this.requestParam).then(response => {
  2116. console.log('合成预混料保存发送参数', this.requestParam)
  2117. if (response.msg === 'fail') {
  2118. const tname = new RegExp("key 'tname'")
  2119. if (tname.test(response.data)) {
  2120. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2121. } else {
  2122. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2123. }
  2124. } else {
  2125. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2126. this.detail.dialogFormVisible = false
  2127. this.getList()
  2128. this.getList2()
  2129. this.getDownList()
  2130. }
  2131. })
  2132. }
  2133. }
  2134. }
  2135. }
  2136. </script>
  2137. <style lang="scss" scoped>
  2138. .search{margin-top:10px;}
  2139. .table{margin-top:10px;}
  2140. .table2{margin-top:10px;}
  2141. $width:350px;
  2142. $left:325px;
  2143. .selectInput{
  2144. position: relative;
  2145. display: inline-block;
  2146. .Input{width: $width;position: relative;}
  2147. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2148. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2149. .selectUl{
  2150. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2151. li{
  2152. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2153. a{float:left;width: 80px;}
  2154. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2155. }
  2156. }
  2157. }
  2158. .template{
  2159. background: #fff;
  2160. position: relative;
  2161. .recipeTemplate{
  2162. width: 72px;
  2163. height: 70px;
  2164. position: absolute;
  2165. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2166. right: 0;
  2167. top: 0;
  2168. margin: 0;
  2169. }
  2170. }
  2171. .detail{
  2172. background: #fff;
  2173. position: relative;
  2174. .recipeDetail{
  2175. width: 72px;
  2176. height: 70px;
  2177. position: absolute;
  2178. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2179. right: 0;
  2180. top: 0;
  2181. margin: 0;
  2182. }
  2183. }
  2184. .templateDialog{
  2185. background: #fff;
  2186. position: relative;
  2187. .recipeTemplate{
  2188. width: 72px;
  2189. height: 70px;
  2190. position: absolute;
  2191. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2192. right: 0;
  2193. top: 0;
  2194. margin: 0;
  2195. }
  2196. }
  2197. .detailDialog{
  2198. background: #fff;
  2199. position: relative;
  2200. .recipeDetail{
  2201. width: 72px;
  2202. height: 70px;
  2203. position: absolute;
  2204. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2205. right: 0;
  2206. top: 0;
  2207. margin: 0;
  2208. }
  2209. }
  2210. </style>